[Devin] fix: add CORS headers to mock API server#8
Open
devin-ai-integration[bot] wants to merge 1 commit intodevin/bug-scanfrom
Open
[Devin] fix: add CORS headers to mock API server#8devin-ai-integration[bot] wants to merge 1 commit intodevin/bug-scanfrom
devin-ai-integration[bot] wants to merge 1 commit intodevin/bug-scanfrom
Conversation
All API routes were missing CORS headers, causing cross-origin requests from the frontend to fail when running on a different origin during development. Added Access-Control-Allow-Origin, Allow-Headers, Allow-Methods headers and OPTIONS preflight handling. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The mock API server has no CORS headers on any route. When the frontend runs on a different origin during development (e.g.,
localhost:5173callinglocalhost:3001), all cross-origin requests fail with CORS errors. This prevents the frontend from communicating with the API in a standard dev setup.Where
File:
api/mock-server.jsLines: 13–20 (where CORS middleware should be)
How I found it
// BUG: Missing CORS headers on all routes.Cross-referencing with the frontend confirmed thatfetch()calls to/api/*would fail cross-origin.Originheader — noAccess-Control-Allow-Originheader was present in responses.Evidence
HTTP scan output (no CORS headers in response):
Fix
Added CORS middleware that:
Access-Control-Allow-Origin: *Access-Control-Allow-Headers: Content-TypeAccess-Control-Allow-Methods: GET, POST, OPTIONSConfidence
High — The commented-out code explicitly documented this as a bug. Standard CORS middleware pattern.
Summary
Adds CORS middleware to the mock API server so cross-origin frontend requests work during development.
Review & Testing Checklist for Human
node api/mock-server.js) and make a cross-origin request — verify CORS headers are presentNotes
Found via static analysis — the code contained a commented-out CORS block that was never activated.
Link to Devin session: https://app.devin.ai/sessions/3b3d59c7eee04cea9069529fd6fff39d
Requested by: @scoobycoder