Skip to content

fix: add CORS headers to API Response#5906

Merged
JarrodMFlesch merged 6 commits into
betafrom
fix/cors
Apr 22, 2024
Merged

fix: add CORS headers to API Response#5906
JarrodMFlesch merged 6 commits into
betafrom
fix/cors

Conversation

@jacobsfletch
Copy link
Copy Markdown
Member

@jacobsfletch jacobsfletch commented Apr 17, 2024

Description

CORS was not setup for API routes. This meant that when working with Payload via an external server running on a different domain or port, it was not possible to use the REST or GraphQL APIs. Now, there's an OPTIONS endpoint to server a preflight response (just as before), and headers are set dynamically on the response based on the cors property of the config (just as before). But unfortunately, we can't do this within Next.js middleware for this exact reason. Middleware currently supports only the Edge Runtime which currently cannot import the Payload config.

  • I have read and understand the CONTRIBUTING.md document in this repository.

@jacobsfletch jacobsfletch marked this pull request as ready for review April 17, 2024 21:36
@JarrodMFlesch JarrodMFlesch merged commit 80c5459 into beta Apr 22, 2024
@JarrodMFlesch JarrodMFlesch deleted the fix/cors branch April 22, 2024 16:13
@JarrodMFlesch JarrodMFlesch changed the title Fix/cors fix: add CORS headers to API Response Apr 22, 2024
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