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
Add proxying support #59
base: master
Are you sure you want to change the base?
Conversation
The configuration parameters `proxyPath` and `proxyUrl` can be used to proxy via http-proxy-middleware.
@@ -36,6 +38,8 @@ server: | |||
serveStatic: | |||
extensions: | |||
- html | |||
proxyPath: undefined | |||
proxyUrl: undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conventionally http://example.com
is of documental usage.
Also for the sake of simplicity I suggest simply pass on the option to http-proxy-middleware directly so people can make most use of the potential.
The following suggestion also remove the proxyPath: undefined
settings.
proxyUrl: undefined | |
httpProxy: | |
context: /foo/bar | |
config: | |
target: http://example.com | |
changeOrigin: true |
Here the naming of httpProxy
corresponds to http-proxy-middleware
, context
, config
to the signature in the document here.
This pull request implements two new
hexo-serve
options that allow a user to proxy certain paths to a remote target. Useful for example to test API integrations when the API endpoints are called via relative URLs from the static part of the site.Example
Assuming that you have your API deployment running locally on port 3001, the following command will proxy all URLs starting with
/api
tolocalhost:3001
.Note: The proxied paths must not already exist in the static part of the site.