Skip to content

Invalid Access-Control-Allow-Origin example in Workers _headers docs #22002

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

Open
viliket opened this issue Apr 27, 2025 · 0 comments
Open

Invalid Access-Control-Allow-Origin example in Workers _headers docs #22002

viliket opened this issue Apr 27, 2025 · 0 comments
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:workers Related to Workers product

Comments

@viliket
Copy link

viliket commented Apr 27, 2025

Existing documentation URL(s)

What changes are you suggesting?

The CORS example in the Workers Static Assets Headers documentation seems to be invalid according to the CORS specification.

Specifically, this example does not work as described:

https://:worker.:subdomain.workers.dev/*
  Access-Control-Allow-Origin: https://*-:worker.:subdomain.workers.dev/

According to the WHATWG Fetch specification, Access-Control-Allow-Origin only accepts:

  • * (all origins)
  • null
  • An exact origin (protocol + domain + port)

Wildcards within origin values like https://*-my-worker.my-subdomain.workers.dev are not supported.

Example of issue

Using the _headers example described in the documentation, when fetching https://my-worker.my-subdomain.workers.dev/asset.png with an origin https://versionprefix-my-worker.my-subdomain.workers.dev, the CORS request fails due to an mismatching Access-Control-Allow-Origin:

Request headers:

OPTIONS /asset.png HTTP/3
Host: my-worker.my-subdomain.workers.dev
Access-Control-Request-Method: GET
Origin: https://versionprefix-my-worker.my-subdomain.workers.dev

Response headers:

HTTP/3 200 OK
Access-Control-Allow-Origin: https://*-my-worker.my-subdomain.workers.dev/

This causes CORS failure as the browser rejects this invalid Access-Control-Allow-Origin header value.

Suggested action

Remove this invalid example from the documentation since it cannot work as described. Alternatively, give an updated example if there is some other workaround.

Additional information

No response

@viliket viliket added content:edit Request for content edits documentation Documentation edits labels Apr 27, 2025
@github-actions github-actions bot added the product:workers Related to Workers product label Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:workers Related to Workers product
Projects
None yet
Development

No branches or pull requests

5 participants