Rewrite not working with external url with the port
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript, node.js
- Domain
- backend
Research direction
Start in serve-handler/src/index.js at toTarget (line 88) and shouldRedirect (line 174), then reproduce the redirects configuration with an external destination containing port 20000. The fix is complete when this redirect no longer throws the path-to-regexp TypeError and forwards to the specified external URL.
Written by the indexing model from the issue text.
Description
Run with configured redirects with the specified port:
"redirects": [
{
"source": "/api/endpoint",
"destination": "http://redirect-url:20000/endpoint"
}
]
Fails with:
INFO Gracefully shutting down. Please wait...
/Users/crbx/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/path-to-regexp@2.2.1/node_modules/path-to-regexp/index.js:194
throw new TypeError('Expected "' + token.name + '" to be ' + (token.repeat ? 'an array' : 'a string'))
^
TypeError: Expected "20000" to be a string
at /Users/user/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/path-to-regexp@2.2.1/node_modules/path-to-regexp/index.js:194:13
at toTarget (/Users/user/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/serve-handler@6.1.5/node_modules/serve-handler/src/index.js:88:9)
at shouldRedirect (/Users/user/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/serve-handler@6.1.5/node_modules/serve-handler/src/index.js:174:18)
at module.exports (/Users/user/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/serve-handler@6.1.5/node_modules/serve-handler/src/index.js:583:19)
at run (file:///Users/user/Library/pnpm/store/v3/tmp/dlx-35334/node_modules/.pnpm/serve@14.2.3/node_modules/serve/build/main.js:181:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
- Dominant language
- JavaScript
- Stars
- 618
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vercel/serve-handler
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
vercel/serve-handler#235 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vercel/serve-handler#231 · 2 comments · 5 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
vercel/serve-handler#165 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
vercel/serve-handler#223 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
vercel/serve-handler#205 · 1 comment · 3 reactions ·
All issues in vercel/serve-handler
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·