Skip to content

Update router cors preflight docs#3277

Merged
reynaldichernando merged 1 commit into
HeyPuter:mainfrom
reynaldichernando:preflight-docs
Jun 19, 2026
Merged

Update router cors preflight docs#3277
reynaldichernando merged 1 commit into
HeyPuter:mainfrom
reynaldichernando:preflight-docs

Conversation

@reynaldichernando

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Workers router documentation to clarify how CORS and preflight OPTIONS requests are handled by default, especially in relation to puter.workers.exec() and the puter-auth header.

Changes:

  • Rewrites the “CORS” section to state that CORS/preflight are handled automatically by the platform/router.
  • Adds guidance that defining an OPTIONS route overrides the default preflight behavior.
  • Condenses the prior explanation into a shorter note about allowing the puter-auth header when overriding preflight.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to +93
CORS is automatically handled for you. Every response includes `Access-Control-Allow-Origin: *`, and preflight `OPTIONS` requests are answered automatically. Cross-origin requests work out of the box, including [`puter.workers.exec()`](/Workers/exec/), which sends the user's Puter token in a custom `puter-auth` header (this is what populates `user.puter`) without you writing any CORS code.

Some requests need a **CORS preflight** first: the browser sends an `OPTIONS` request and waits for the allowed methods and headers before sending the real one. This happens when the request uses a method like `PUT` or `DELETE`, or carries custom headers (e.g. `Authorization`).

To handle this, you can add an `OPTIONS` handler that returns the methods and headers you want to allow:
You only need to think about CORS if you define your own `OPTIONS` handler. Doing so takes over preflight handling, so you become responsible for the headers the browser expects:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change behavior of the auto handling to support PUT and DELETE

@reynaldichernando reynaldichernando merged commit e2174a1 into HeyPuter:main Jun 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants