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

Target path is not being set correctly when prepending path #5

Closed
jonasolesen opened this issue Aug 26, 2023 · 0 comments
Closed

Target path is not being set correctly when prepending path #5

jonasolesen opened this issue Aug 26, 2023 · 0 comments

Comments

@jonasolesen
Copy link
Contributor

Environment

Package version 0.1.2
Node.js 18.16.0

Reproduction

I initially reproduced the error by using nitro and configuring the devProxy like so:

devProxy: {
  "/posts": {
    target: "https://jsonplaceholder.typicode.com/posts",
    changeOrigin: true,
    prependPath: true,
  },
},

It turned out to be a bug with httpxy instead, but I figured the reproduction would be obvious enough using the nitro playground with the above configuration rather than forking the repo.

Describe the bug

Using the provided configuration, I assume the expected behavior would be to proxy a request to the /posts path to https://jsonplaceholder.typicode.com/posts, but it seems to be forwarded to just https://jsonplaceholder.typicode.com instead. I (supposedly) fixed the bug by changing the property used when determining the target path from path to pathname as per the URL class API documentation. I'll submit a PR shortly.

Additional context

Another issue reporting the bug: unjs/nitro#1643

Logs

No response

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

No branches or pull requests

2 participants