Port issues when returning a 301 redirect #111021
Replies: 4 comments 1 reply
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Commenting to see if I can get the "inactive" flag to go away. |
Beta Was this translation helpful? Give feedback.
-
I ran into this with FastAPI and RedirectResponse, due to url_for using absolute URLs. Changing the redirect to a relative URL fixed the issue, since Codespace doesn't rewrite those. From: return RedirectResponse(url=request.url_for('details', id=restaurant.id), status_code=status.HTTP_303_SEE_OTHER) To: return RedirectResponse(url=app.url_path_for("details", id=restaurant.id), status_code=status.HTTP_303_SEE_OTHER) |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
I am running an Nginx reverse proxy, deployed via a
dockerComposeFile
in mydevcontainer.json
, in front of a couple of services that are running within my codespace. This proxy is listening on port 8080, which is listed in theforwardPorts
key of my devcontainer.json. I can go tohttps://CODESPACENAME-8080.app.github.dev:443/
and it works as expected, all the rewrites I've set up for the backend servers running in my codespace work correctly, so far so good.The issue I'm having is with redirects. I'd like to make the Nginx server return a 301 redirect to
/path-b
when the user goes tohttps://CODESPACENAME-8080.app.github.dev:443/path-a
. I can't figure out how to get this to work. If I configure/path-a
to return a 301 tolocalhost:8080/path-b
, this appears to get rewritten tohttps://CODESPACENAME-8080.app.github.dev:8080/path-b
when the user visitshttps://CODESPACENAME-8080.app.github.dev:443/path-a
. This obviously doesn't work - the port requested in the browser shouldn't actually be 8080. But if I remove the:8080
from the URL that I'm redirecting to, that also doesn't work: in that case, I end up with a redirect tohttps://CODESPACENAME-80.app.github.dev:443/path-b
.I'm not looking for Nginx help specifically, just trying to figure out what kind of response my server should send in order to properly redirect the user to a codespace URL with the port set correctly.
Do I need to compute the exact Codespaces
CODESPACENAME-8080.app.github.dev
domain and redirect to that explicitly? If so, how can I pass theCODESPACE_NAME
andGITHUB_CODESPACES_PORT_FORWARDING_DOMAIN
environment variables to the container that I'm running in Docker Compose? I found this doc about environment variables in dev containers in general, but it wasn't clear to me how this interacts with the environment variables that are populated by Codespaces.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions