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

Specify full address for rewrite destination? #28

Closed
simonedavico opened this issue Jun 14, 2018 · 3 comments
Closed

Specify full address for rewrite destination? #28

simonedavico opened this issue Jun 14, 2018 · 3 comments

Comments

@simonedavico
Copy link

simonedavico commented Jun 14, 2018

I am launching serve with a serve.json file. I have a rewrite like this:

{
  "source": "/foo/api/:rest",
  "destination": "http:/xxx.xx.x.xx:8080/foo/api/:rest"
}

But this causes an error when I launch serve:

(node:14574) UnhandledPromiseRejectionWarning: TypeError: Expected "8080" to be a string
    at /Users/sdavico/Development/installer/webapp/node_modules/serve-handler/node_modules/path-to-regexp/index.js:194:13
    at toTarget (/Users/sdavico/Development/installer/webapp/node_modules/serve-handler/src/index.js:68:9)
    at applyRewrites (/Users/sdavico/Development/installer/webapp/node_modules/serve-handler/src/index.js:85:18)
    at module.exports (/Users/sdavico/Development/installer/webapp/node_modules/serve-handler/src/index.js:547:24)
    at Server.http.createServer (/Users/sdavico/Development/installer/webapp/node_modules/serve/bin/serve.js:147:58)
    at Server.emit (events.js:160:13)
    at parserOnIncoming (_http_server.js:618:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:115:23)

This is due to using path-to-regexp to process the destination. Could we add support for full URLs?

@chiefjester
Copy link

@simonedavico rewrites are for rewriting to internal paths, and doesn't support external URLs if that's what you were aiming?

@simonedavico
Copy link
Author

Yes, I was indeed aiming for the ability to proxy my API calls to an external address. In the end I had to switch to light-server, which supports this option. It would be nice too see this in serve-handler as well, if it's not out of scope w.r.t the purpose of the package.

@leo
Copy link
Contributor

leo commented Jun 15, 2018

Closed in favor of #30

@leo leo closed this as completed Jun 15, 2018
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

3 participants