[BUG]: Drizzle Studio CORS error
Problem
What version of `drizzle-orm` are you using? 0.29.3 What version of `drizzle-kit` are you using? 0.20.13 Describe the Bug Unable to use drizzle-studio due to CORS error. 1. Visit https://local.drizzle.studio/ 2. Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:4983/. (Reason: CORS request did not succeed). Status code: (null). Expected behavior _No response_ Environment & setup _No response_
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix CORS Error in Drizzle Studio Configuration
The CORS error occurs because the server at http://localhost:4983/ is not configured to allow requests from the origin https://local.drizzle.studio/. This is a common issue when the server does not include the appropriate CORS headers in its response, preventing the browser from accessing the resource due to the Same Origin Policy.
Awaiting Verification
Be the first to verify this fix
- 1
Update Server CORS Configuration
Modify the server configuration to include CORS headers that allow requests from the Drizzle Studio origin. This can typically be done by adding middleware to your server application.
javascriptconst cors = require('cors'); app.use(cors({ origin: 'https://local.drizzle.studio' })); - 2
Restart the Server
After updating the CORS configuration, restart your server to apply the changes. This ensures that the new settings are in effect.
bashnpm restart - 3
Verify CORS Headers
Use a tool like Postman or your browser's developer tools to check the response headers from http://localhost:4983/. Ensure that the 'Access-Control-Allow-Origin' header includes 'https://local.drizzle.studio'.
bashcurl -I http://localhost:4983/ - 4
Test Drizzle Studio Access
Visit https://local.drizzle.studio/ again to confirm that the CORS error no longer appears and that you can access the application without issues.
Validation
To confirm the fix worked, ensure that you can access the Drizzle Studio without encountering the CORS error. Check the browser console for any CORS-related messages and verify that the application loads successfully.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep