|
Hmm, haven't you gone round in a circle here? Isn't this what introducing the reverse proxy should have solved? You should not have to mess around with CORS to get this to work. If the index.html is being served from the same host as the API (or apparently the same host because of the reverse proxy) then it should just work. If you are serving the index.html from a local web server on your PC then you must configure this as a reverse proxy as well so that it redirects API calls to the real host. If you are just opening the HTML file directly in the browser then it will not work, it needs to be served from a local web server like this, for example, https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fhttp-server&data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&sdata=ecTATkDOrNrHnhS2sw4R3rs1RFYkbYZY6X9jt767ocU%3D&reserved=0 However, in both the latter cases it wouldn't work at all unless you are using absolute URLs for your AJAX API calls, which you shouldn't be, so all AJAX calls should be to '/api/someendpoint...' not 'https://nam02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fan.ip%2Fapi%2Fsomeendpoint&data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&sdata=4Vc9%2Ff7C%2Beu5gmTOGd4oKOJXOq7l7h6%2BwjDIWN6Ueao%3D&reserved=0'.--
It sounds to me like you're just opening the index.html locally and in it you have used absolute URLs to the API, which won't work, if so, try this.
1) change any absolute URLs in your index.html to relative ones
2) install http-server
> npm install http-server -g
3) cd <to_where_your_index.html_is>
4) run the server, proxying unknown URLs to your API...
> http-server --proxy http://youribmi/api
5) point your browser at localhost:8080 and your page should work as expected
Tim.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.