ReactJS App Subdomain

I have Coder working well with everything in my stack (Java and ReactJS), but the only issue I'm having is when trying to access a part of my ReactJS app that exists under a subdomain. For example. when running locally I'm able to do localhost:5173 to get to a "Control Panel" version of the app, but then to get to another part I have to do subdomain.localhost:5173. I have no problems with the root (Control Panel) but I can't figure out how to get the subdomains to resolve. Not sure what config to post here since I'm new to Coder, but I can supply whatever is needed.
13 Replies
Codercord
Codercord6mo ago
Codercord
Codercord6mo ago
<#1369433180527923402>
Category
Help needed
Product
code-server
Platform
Windows
Logs
Please post any relevant logs/error messages.
zounce
zounce6mo ago
Just to clarify, you're running something like coder port-forward <ws> --tcp 5173:5173? and localhost:5173 works fine, but not subdomain.localhost:5173? I would expect that to just work, so this might be a bug (actually, if the app running on your workspace is programming the localhost subdomain by modifying /etc/hosts, then it makes sense this doesn't work out the box) Do you know how your react app programs subdomain.localhost to point to your server?
whitesoup12
whitesoup12OP5mo ago
To clarify, I'm not actually using localhost to access my apps. I'm. using my coder URL (eg. ****.try.coder.app:5173). It's when I try to access subdomain.****.try.coder.app that I have the issue. The ReactJS app actually just grabs the subdomain and displays a different section of the app, so technically not a real subdomain. As for coder port-forward, I have yet to get that to work. My workspace name for UI is RemoteFalconUI, but when I try to port forward, I always end up with an error. coder port-forward RemoteFalconUI --tcp 5173:5173 Encountered an error running "coder port-forward", see "coder port-forward --help" for more information error: Resource not found or you do not have access to this resource Update. I was finally able to get port-forward working. I tried a multitude of workspace names before finding out coder list will give the workspaces the CLI uses (which was user/workspace). With port-forward working I can now access all parts of the app.
zounce
zounce5mo ago
That's good to hear! Was it just that the workspace you were trying to port-forward owned by someone else?
Phorcys
Phorcys5mo ago
that makes sense, also regarding the port-forwarding I would recommend configuring your own domain instead of relying on try.coder.app! and yeah, we don't support sub-subdomains for the port-forwarding as we're already using a wildcard domain for port-forwarding
whitesoup12
whitesoup12OP5mo ago
No, I own it. I was just using the wrong workspace name.
Phorcys
Phorcys5mo ago
you shouldn't need to specify the user/ part when it's your workspace are you logged in as the same user? coder whoami
whitesoup12
whitesoup12OP5mo ago
Yeah, I’m logged in as the same user. I did also notice I had a typo in my workspace name. When I was trying to port forward, I was spelling it without the typo. 🤦. So it does work without the user as well.
Phorcys
Phorcys5mo ago
ah alright that does make sense i was scared that we had a bug!
whitesoup12
whitesoup12OP5mo ago
Nope, all good! Just user error on my part. I appreciate the follow up!
Phorcys
Phorcys5mo ago
sounds good! i'll close this issue now that everything seems to be solved :-)
Codercord
Codercord5mo ago
@Phorcys closed the thread.

Did you find this page helpful?