Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Explicitly allow requests from public websites via new header #302

Merged
merged 1 commit into from
Feb 19, 2022

Conversation

killergerbah
Copy link
Contributor

@killergerbah killergerbah commented Feb 16, 2022

- Chrome now enforces that servers on private networks explicitly
  grant access to public websites using a new header
  "Access-Control-Allow-Private-Network" that should be sent in
  responses to preflight OPTIONS requests.
- This change implements special handling for OPTIONS requests by
  sending all the existing CORS headers along with the new
  Access-Control-Allow-Private-Network header if private network
  access is being requested.
- See https://developer.chrome.com/blog/private-network-access-preflight/
  for more info.

This PR would fix #301

Unfortunately, requestPermission will continue to not work for browsers that send the OPTIONS request, as the browser will now fail such requests due to the CORS check resulting from the OPTIONS response. A real fix for requestPermission could involve bigger change that puts the requestPermission action on a different endpoint, so that the OPTIONS request for that endpoint could serve a separate origin whitelist.

- Chrome now enforces that servers on private networks explicitly
  grant access to public websites using a new header
  "Access-Control-Allow-Private-Network" that should be sent in
  responses to preflight OPTIONS requests.
- This change implements special handling for OPTIONS requests by
  sending all the existing CORS headers along with the new
  Access-Control-Allow-Private-Network header if private network
  access is being requested.
- See https://developer.chrome.com/blog/private-network-access-preflight/
  for more info.
@FooSoft
Copy link
Owner

FooSoft commented Feb 19, 2022

Great work, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Options to handle preflight requests with the Access-Control-Allow-Private-Network header
2 participants