-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot access server on the local network (missing "Access-Control-Allow-Private-Network: true" header). #61
Comments
Hello, the problem is that you are using https on your local machine instead of http. This is normally not needed and causes this error. You connect to your own machine with SSL encryption, which is useless. The browsers block this. Regards, |
Well, ssl was a last ditch effort to see if it solved the problem. It's the same with plain http. It's a safety feature, to avoid that an external site (in this case github) can access internal resources, unless the internal resource allows access with the "Access-Control-Allow-Private-Network:true". At least that's what I understood reading the documentation (which I didn't study thoroughly so it's very well possible that I didn't understand correctly how to solve the problem). |
(btw: localhost was the second attempt with an ssh tunnel since I got the error accessing the real, internal, machine, which is not the same where I'm running the browser). |
The "Access-Control-Allow-Origin: *" is ther, what's missing is the "Access-Control-Allow-Private-Network: true", see here: The setup is simple: I was pointing the frontend to another host in the internal network, got the error, tried localhost (with an ssh tunnel), same error, tried ssl. |
I can set the header, no problem, but it's not necessary. I just tried it out. If your computer, where you are accessing the GitHub page, has the IP 192.168.1.10 and your endpoint has the IP 192.168.1.20, then you must use HTTPS (this is a browser restriction). HTTP is only allowed for localhost. You're probably using a self-signed certificate. In that case, you need to first access your endpoint in the browser (https://192.168.1.20:6176/) and accept the certificate. Then you can enter the URL in your client machine as the endpoint address, and everything should work. This is also explained in the FAQ |
Never mind. I added the header myself. Now the problem is that apple has disabled my id and I cannot create a new one right now. |
Solved the issue with the apple id, I can now confirm that without the header it doesn't work, with the header it does.
to the end of the |
I will add this header to the server, but I don't really understand why this is needed in your setup and not on mine. |
I don't understand either, maybe a different version of the browser or something in about:config that makes it more lenient in your case. I also don't get 100% the security implications of adding the header but I don't think it would be a problem for this application. |
Fixed in v.2.20 |
If I'm using your frontend hosted on github, I cannot access the server on the local network (or on localhost) because:
Access to XMLHttpRequest at 'https://localhost:6176/' from origin 'https://dchristl.github.io' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Private-Network' header was present in the preflight response for this private network request targeting the
localaddress space.
This is on chromium, firefox reports the same issue but less verbosely:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://localhost:6176/. (Reason: CORS request did not succeed). Status code: (null).
The text was updated successfully, but these errors were encountered: