Skip to content

fix: restore CORS headers on /api/libraries#2522

Merged
Simek merged 1 commit into
react-native-community:mainfrom
amandeepmittal:aman/add-cors-in-next-config
Jun 15, 2026
Merged

fix: restore CORS headers on /api/libraries#2522
Simek merged 1 commit into
react-native-community:mainfrom
amandeepmittal:aman/add-cors-in-next-config

Conversation

@amandeepmittal

@amandeepmittal amandeepmittal commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📝 Why & how

PR #2520 rewrote the headers() array in next.config.ts and inadvertently dropped the existing /api/libraries CORS entry. As a result, the endpoint stopped sending Access-Control-Allow-Origin in production.

CleanShot 2026-06-15 at 16 39 32@2x

This breaks every cross-origin browser consumer of the API. In particular, the React Native Directory results in the Expo docs search command menu (docs.expo.dev) now fail with "blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present" followed by "Uncaught (in promise) TypeError: Failed to fetch", which takes down the whole search dialog rather than just the directory section.

This PR re-adds the /api/libraries CORS rule to the headers() array in next.config.ts.

✅ Checklist

  • Added library to react-native-libraries.json
  • Updated library in react-native-libraries.json
  • Documented how you found or replicated the issue.
  • Explained how you fixed the issue or built the feature.
  • Described how to use or verify the change.

@Simek Simek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey Aman, heh, I was wondering why it's required, now I remember. 🙂

Thanks for catching and restoring headers. 👍

@Simek Simek merged commit 02d4dbc into react-native-community:main Jun 15, 2026
1 check passed
@amandeepmittal

Copy link
Copy Markdown
Contributor Author

Hey Aman, heh, I was wondering why it's required, now I remember. 🙂

Thanks for catching and restoring headers. 👍

haha

Thank you for taking a look at this PR so quickly!

Expo docs and its users thank you ❤️

@amandeepmittal amandeepmittal deleted the aman/add-cors-in-next-config branch June 15, 2026 12:19
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