-
Hello, But when the page from github pages tries to access the data, the browser console shows The server has CORS enabled (it is the loopback 4 framework that has CORS enabled by default). Is there anything I need to do in the app under GH? |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 1 reply
-
Hello, Does your Pages site has its visibility set to private? Pages allows CORS ( This is the current (sensitive) behavior in place until we can support custom headers. |
Beta Was this translation helpful? Give feedback.
-
No the site is public. |
Beta Was this translation helpful? Give feedback.
-
Only thing I can think of is extra restrictions your browser would put on. Say if |
Beta Was this translation helpful? Give feedback.
-
The server VM is local but within the code on github, it points to my ISP allocated IP address and the port forwarding gets it to the VM. |
Beta Was this translation helpful? Give feedback.
-
I have added “mode” (cors) to the fetch request along with a header of “Access-Control-Allow-Origin” (the IP address of my ISP connection).
Now this is the first time I have had a reason that mentioned Access-Control-Allow-Origin. It is also the first time that I specifically added Access-Control-Allow-Origin to the headers in the fetch request. Which is all very confusing. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
@airtower-luna, thank you for this. |
Beta Was this translation helpful? Give feedback.
-
So I solved this. Nothing to do with github pages or svelte. |
Beta Was this translation helpful? Give feedback.
-
Can you be more precise about how you solved this problem |
Beta Was this translation helpful? Give feedback.
-
Hello @Sam-cudo, I have two entries for CORS because the frontend code is either running on a local svelte server (localhost/PC) or on github. I hope this helps. The key thing for me was realising that the backend had to know where to expect requests to come from; in my case either github.io or my local svelte server (or apache or nginx or whatever) |
Beta Was this translation helpful? Give feedback.
-
Any update about it? |
Beta Was this translation helpful? Give feedback.
So I solved this. Nothing to do with github pages or svelte.
I was using the cors origin value in the rest server as the url of the server. It needs to be the github.io url.