Skip to content
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

Proxying does not respect lack of trailing slash #330

Closed
noc7c9 opened this issue Mar 5, 2022 · 2 comments · Fixed by #507
Closed

Proxying does not respect lack of trailing slash #330

noc7c9 opened this issue Mar 5, 2022 · 2 comments · Fixed by #507

Comments

@noc7c9
Copy link

noc7c9 commented Mar 5, 2022

Say I have a test API that echos back the URI path that was called.

Note: API is running on 3000

$ curl http://localhost:3000/api
CALLED: /api

$ curl http://localhost:3000/api/
CALLED: /api/

When setting up Trunk to proxy to this endpoint it proxies to /api/ when when the original path was /api.

$ trunk --version
trunk 0.14.0
$ trunk serve --proxy-backend http://localhost:3000/api
...
Mar 05 15:23:02.819  INFO 📡 proxying /api -> http://localhost:3000/api
Mar 05 15:23:02.819  INFO 📡 server listening at 0.0.0.0:8080

$ curl http://localhost:8080/api
CALLED: /api/

$ curl http://localhost:8080/api/
CALLED: /api/

Not the biggest deal by itself but my actual API server is set to redirect /api/ to /api which causes proxying to fail.

# calling the "actual" API server now
$ curl http://localhost:3000/api
CALLED: /api

$ curl -v http://localhost:3000/api/
...
< HTTP/1.1 308 Permanent Redirect
< location: /api
...

# calling via Trunk
$ curl -v http://localhost:8080/api
...
< HTTP/1.1 308 Permanent Redirect
< location: /api
...

$ curl -v http://localhost:8080/api/
...
< HTTP/1.1 308 Permanent Redirect
< location: /api
...

PS: thanks for the amazing project, it's honestly a lifesaver. Makes working with WASM an absolute joy tbh.

@usagi
Copy link

usagi commented Sep 13, 2022

I had trouble with this issue too. 🥺 This is an extraneous feature. I think It is better to optional and could be disabled as standard.

@Ekleog
Copy link

Ekleog commented Nov 13, 2022

FWIW, it seems to only happen when proxying requests to the root redirect.

Assuming trunk serve --proxy-backend http://localhost:3000/api, then:

  • curl http://localhost:8080/api gets rewritten to http://localhost:3000/api/ (the issue)
  • curl http://localhost:8080/api/foobar gets rewritten to http://localhost:3000/api/foobar (so no issue here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants