-
Notifications
You must be signed in to change notification settings - Fork 267
Handle CORS requests for only defined agent routes #457
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 7cc567e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
corsHeaders = {}; | ||
} | ||
|
||
const response = await routePartykitRequest(request, env as any, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can replace these any
if needed but it's something that needs to be fixed in partyserver
imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put it back the way it was for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in use Record
over any
?
corsHeaders = {}; | ||
} | ||
|
||
const response = await routePartykitRequest(request, env as any, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's put it back the way it was for now
console.warn( | ||
"Received an OPTIONS request, but cors was not enabled. Pass `cors: true` or `cors: { ...custom cors headers }` to routeAgentRequest to enable CORS." | ||
); | ||
if (resolvedRequest.method === "OPTIONS") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we want to do this check before calling onBeforeRequest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a user I would assume options.onBeforeRequest()
of routeAgentRequest()
will be called before anything else.
Currently
routeAgentRequest()
resolves anyOPTIONS
request it receives, regardless of the request path. This PR updatesrouteAgentRequest()
to handle preflight requests only for defined agent routes (/agents/NAMESPACE/NAME
and its subroutes).I also improved the JSDoc a bit.