question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing API tab on self hosted instance results in CORS error.

See original GitHub issue

Bug 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: image

Opening dev tools shows these errors:

image

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Hergeirscommented, Feb 21, 2022

It did. I should have seen that myself instead of blindly copying the .env.examples file. Thank you.

0reactions
unuseccommented, Apr 13, 2022

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found