Accessing API tab on self hosted instance results in CORS error.
See original GitHub issueBug report
Describe the bug
Self hosting Supabase following the guide in https://supabase.com/docs/guides/hosting/docker results in a CORS error when accessing the API tab in the studio. I’ve done no changes to anything. Not even created a table. I have tried creating a table as well and it made no difference.
To Reproduce
Steps to reproduce the behavior:
Follow the guide in https://supabase.com/docs/guides/hosting/docker
# Get the code
git clone --depth 1 https://github.com/supabase/supabase
# Go to the docker folder
cd supabase/docker
# Copy the fake env vars
cp .env.example .env
# Start
docker-compose up
go to localhost:3000 with a browser and click the API tab on the left
Get an error:
Opening dev tools shows these errors:
In text form:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://kong:8000/rest/v1/?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE. (Reason: CORS request did not succeed). Status code: (null).
load e.message An error has occured: NetworkError when attempting to fetch resource. [_app-6e0e1cfab749f6b0e74d.js:1:1030291](http://localhost:3000/_next/static/chunks/pages/_app-6e0e1cfab749f6b0e74d.js)
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://kong:8000/rest/v1/?apikey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE. (Reason: CORS request did not succeed). Status code: (null).
Expected behavior
Showing the expected API tab.
System information
- OS: archlinux
- Browser: Firefox 97.0 (64-bit)
Additional context
None relevant.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Troubleshoot CORS errors from API Gateway - Amazon AWS
Cross-Origin Resource Sharing (CORS) errors occur when a server doesn't return the HTTP headers required by the CORS standard. To resolve a CORS ......
Read more >I got a CORS error, now what? - DEV Community
CORS or Cross-Origin Resource Sharing, means that your website is running on a different domain than the API you are calling: Website: https:// ......
Read more >Tutorial: Host RESTful API with CORS - Azure App Service
Navigate to the browser app at http://localhost:5000 . Open the developer tools window in your browser ( Ctrl + Shift + i in...
Read more >3 Ways to Fix the CORS Error — and How the Access-Control ...
Fix one: install the Allow-Control-Allow-Origin plugin. The quickest fix you can make is to install the moesif CORS extension .
Read more >How to solve 'Redirect has been blocked by CORS policy
The issue is because the Same Origin Policy is preventing the response from being received due to the originating/receiving domains being ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It did. I should have seen that myself instead of blindly copying the .env.examples file. Thank you.
@ryanfiller in the .env file, if you run supabase on another machine in your lan make sure to use the LAN IP for the PUBLIC_REST_URL and SITE_URL, I had a similar issue with a supabase install on my NAS