Port Visibility & CORS #15351
Replies: 10 comments 14 replies
-
I have the same problem as well. anyone had any luck solving this without using public visibility? |
Beta Was this translation helpful? Give feedback.
-
Unfortunately we have the same problem, did anyone find a solution? |
Beta Was this translation helpful? Give feedback.
-
The only solution I have currently found other than manually setting this via the gui is running: gh codespace ports visibility 3000:public -c $CODESPACE_NAME In the codespace terminal. However, that only works once the port has been forwarded, and I still don't have a consistent way of automatically running the command once the server is up. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm facing the same issue. Is there any other solution to provide CORS headers without changing to public? |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell this is due to the fact that the preflight OPTIONS request is not supposed to contain authentication information (and the browser does not send it!), but the GitHub Codespaces server is expecting this info and otherwise rejects the request.
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#requests_with_credentials I ran into the same issue with Gitpod and made a detailed bug report for them, so far without response. gitpod-io/gitpod#14576 To me it seems to be exactly the same issue and considering how similar Gitpod and GitHub Codespaces look, I assume they are based on the same code base. EDIT: As mentioned in a different comment, I created an example repository to reproduce this issue. https://github.com/omarkohl/gh-codespaces-cors |
Beta Was this translation helpful? Give feedback.
-
Hey @chadhietala- thanks for the report! This is a known issue, and we are determining the best approach to fix it. @omarkohl is exactly right that the underlying issue is the Using public ports will work, but you can also work around this by connecting to your codespace via VS Code Desktop rather than the web based browser. VS Code Desktop enables you to privately forward ports from your codespace to your local machine directly (at This workaround does not help for org-based ports though since those require publicly accessible URLs, which will fail on authentication again. |
Beta Was this translation helpful? Give feedback.
-
I disable chrome plugin: |
Beta Was this translation helpful? Give feedback.
-
Helped me solve my problem. Thanks for sharing. |
Beta Was this translation helpful? Give feedback.
-
so 2 years later and no answer?? |
Beta Was this translation helpful? Give feedback.
-
In my case, port 5000 was still returning a CORS error even after stopping my container app. I ran lsof -i :5000 to check if something else was using this port locally, and I found the following running on port 5000:
I discovered this process was related to macOS AirPlay. I changed my container app to use a different port, and that resolved the issue. |
Beta Was this translation helpful? Give feedback.
-
I spent the past couple days trying to figure out how to resolve a CORS related problem within Github Codespaces. Consider the following scenario:
fetch
a todos from https://chad-my-project-abc231-7007.githubpreview.dev/api/todosAs of right now the only way you can do this is if you set the port visibility on the API server (7007) to Public. Both Private and Private to Organization seem to block the requests. I believe that there is a need to make the port accessible to the organization but not Public.
With Public Port Visibility
With Private to Organization Port Visibility
Beta Was this translation helpful? Give feedback.
All reactions