...sorry, it wasn't meant to come across all school-teachery! It might be easy to describe exactly what you're trying to do and how, then maybe I can help a bit better. Stick at it, we've all been there!

Tim.

________________________________
From: WEB400 <web400-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Booth Martin <booth@xxxxxxxxxxxx>
Sent: 06 April 2019 20:33
To: Web Enabling the IBM i (AS/400 and iSeries)
Subject: Re: [WEB400] CORS header 'Access-Control-Allow-Origin'

Thank you. In 4th grade I had to take a note to the teacher in 8th
grade. They were doing math. I just read your response and I have the
same feeling I had then...

You realize it'll take me at least a week to figure this out. *grin*
It'll keep me busy and out of the beer halls and brothels, right?
That's a good thing. Thank you.

On 4/6/2019 4:30 AM, Tim Fathers wrote:
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&amp;data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&amp;sdata=ecTATkDOrNrHnhS2sw4R3rs1RFYkbYZY6X9jt767ocU%3D&amp;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&amp;data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&amp;sdata=4Vc9%2Ff7C%2Beu5gmTOGd4oKOJXOq7l7h6%2BwjDIWN6Ueao%3D&amp;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.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.midrange.com%2Fmailman%2Flistinfo%2Fweb400&amp;data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&amp;sdata=tFCqoOZkBAdpO4mpY2VmY5fuQzEtSv5QJhjHEkctvgc%3D&amp;reserved=0
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Farchive.midrange.com%2Fweb400&amp;data=02%7C01%7C%7C644430669b4347d9731c08d6babe6e8e%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636901724386940893&amp;sdata=0UUQ1FAqxjX2rW5OiEQt%2FjrwzE7qPuywitl9Rgsbpm0%3D&amp;reserved=0.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.