-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code-server's reverse proxy seems to always return index.html for all resources #2222
Comments
code-server rewrites the URL by stripping the base out when proxying so when a request is made for It looks like So I think we need some kind of mechanism for deciding when we should rewrite the URL and when we shouldn't although maybe we should just default to not rewriting it since I think that might be the more common behavior. |
I'm having a similar problem, but with flutter. When I try to open https://mydomain.org/code/proxy/8990/ I can see the error: Even when trying on my local network, https://192.168.1.94:8443/proxy/8990/ : Looks like is also not expecting the base path to be stripped out. |
I think the base path should be adjusted to work behind the proxy correctly. It's the most portable solution as you can easily remove the proxy in front and your app will still work if you access it locally. I do think it'd be useful to check what popular proxies do by default. |
Hey @erlloyd - sorry to hear about the issue! We'll see what we can do about this. I'm familiar with React but haven't used it with a proxy or "the 'website' field expected by React" that you're referring to. Do you mind providing steps to reproduce your issue locally (i.e. without Docker)? That'll help me resolve this faster. Thank you! |
@jsjoeio The problem is actually very easy to repro, I'll list the steps here. The confusion might be that I mistakenly said 'website' field, when I meant the 'homepage' field in
If you navigate to Let me know if that isn't working for you to repro the problem! |
@erlloyd Thanks a ton for the quick response and the detailed steps 🙏 I was able to reproduce it locally. I'll see what options we have to fix this. |
Awesome @jsjoeio! Thanks for the update and enjoy your vacation. |
Hey all! I wanted to post an update. This is my first priority this week. I’ve had some laptop issues which should get resolved tomorrow. I have made a little bit of progress though which you can see if you look at the commits for |
I don't think this is a bug. Its just how the proxy works. See #2485 |
e.g. for your |
@nhooyr I would love if you could provide an example react app created via create-react-app where this would work! If you don't provide the |
This is what you get with a default create-react-app install trying to access it via the proxy: The index.html file is loaded fine, but you can see that react has generated non-relative paths. The default
|
My bad. I guess it wouldn't work by default but see that note at the bottom:
I'll give it a shot hopefully sometime tomorrow and see what the correct configuration here is and then we can document it as part of #2485 |
Thanks @nhooyr . Funny enough, that note at the bottom refers to setting the |
There appears to be a bunch of See
It appears to work correctly for Let's add a configuration flag here to allow the proxy to pass through paths. We should still report this to the create-react-app team and have them properly fix it. I'm thinking |
Actually, we can read the |
Fixed with |
I think we should look into being able to specify this flag for each workspace / folder separately since there will be some projects that use relative paths, some that don't and restarting the code-server with changed flag is not feasible? |
@meetmangukiya Perhaps we could add a second proxy endpoint that passes through the path? Like |
See coder#2222 (comment) Makes way more sense.
Added in #2674 |
See coder#2222 (comment) Makes way more sense.
@nhooyr this is awesome, thanks! wont need to restart the server now and still have project specific choice between absolute and relative paths |
See coder#2222 (comment) Makes way more sense.
I posted this on stackoverflow because I am one of the many learning react from udemy/youtube with vs code server who get stucked. |
i dont see any option to work with expo cli |
@zakrian07 what are you trying to do? |
I’m on expo cli web and trying to do /proxy/19006
…On Sat, Jan 21, 2023 at 3:40 AM Joe Previte ***@***.***> wrote:
@zakrian07 <https://github.com/zakrian07> what are you trying to do?
—
Reply to this email directly, view it on GitHub
<#2222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABPI5XKXDU3ILMJEIXNK6GDWTMH6FANCNFSM4S2SFARA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Feel free to open a Discussion with more information and I'd be happy to help! |
PUBLIC_URL=/absproxy/3000 WDS_SOCKET_PATH=$PUBLIC_URL/sockjs-node BROWSER=none npm start This will give you the React app preview instead of npm start with the above command. Happy Hacking! |
code-server --version
: 3.5.0 de41646I'm running a vanilla react project created via
create-react-app
. I'm trying to use code-server's built-in proxy to view my application. I set my sites 'website' field as expected by react to behttp://<code-server-machine-ip>:8443/proxy/3000
. However, when I go to that address, every one of the assets loaded (all .js files, the favicon) seem to be the index.html. I get an error like this in the console:Uncaught SyntaxError: Unexpected token '<' bundle.js:1
This feels like a bug in the proxy layer of code-server, but I'm hoping I just have something configured incorrectly. I'm running code-server via docker image if that makes a difference.
The text was updated successfully, but these errors were encountered: