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

Add proxying support #59

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add proxying support #59

wants to merge 6 commits into from

Conversation

17320
Copy link

@17320 17320 commented Oct 5, 2018

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 to localhost:3001.

hexo serve -P /api -U http:localhost:3001/

Note: The proxied paths must not already exist in the static part of the site.

The configuration parameters `proxyPath` and `proxyUrl` can be
used to proxy via http-proxy-middleware.
@coveralls
Copy link

coveralls commented Oct 5, 2018

Coverage Status

Coverage decreased (-0.4%) to 94.118% when pulling c63f521 on 17320:add-proxy-support into de57a80 on hexojs:master.

@@ -36,6 +38,8 @@ server:
serveStatic:
extensions:
- html
proxyPath: undefined
proxyUrl: undefined
Copy link
Contributor

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.

Suggested change
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.

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

Successfully merging this pull request may close these issues.

None yet

3 participants