Skip to content

Commit

Permalink
feat(proxy): set default value of proxy.changeOrigin to true (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuchaoying committed Aug 26, 2019
1 parent 0999450 commit 627db59
Show file tree
Hide file tree
Showing 5 changed files with 643 additions and 6,092 deletions.
1 change: 0 additions & 1 deletion examples/proxy/.svrxrc.js
Expand Up @@ -6,7 +6,6 @@ module.exports = {
{
context: ['/api', '/same'],
target: 'https://randomuser.me',
changeOrigin: true,
pathRewrite: {
'/same/api': '/api'
}
Expand Down
50 changes: 22 additions & 28 deletions packages/svrx-util/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/svrx/__tests__/spec/svrx.plugin.proxy.js
Expand Up @@ -14,10 +14,10 @@ describe('Proxy Action', async () => {
const { route } = router;
route(({ get }) => {
get('/api(.*)').to.proxy(PROXY_SERVER);
get('/origin/api/test').to.proxy(PROXY_SERVER, {
changeOrigin: true,
get('/origin/api/test').to.proxy(PROXY_SERVER);
get('/origin/api/noset').to.proxy(PROXY_SERVER, {
changeOrigin: false,
});
get('/origin/api/noset').to.proxy(PROXY_SERVER);
get('/rewrite/api(.*)').to.proxy(PROXY_SERVER, {
pathRewrite: {
'^/rewrite/api': '/api',
Expand Down
2 changes: 1 addition & 1 deletion packages/svrx/lib/plugin/svrx-plugin-proxy/index.js
Expand Up @@ -50,7 +50,7 @@ function hasPort(host) {

async function proxy({ proxyRule, ctx }) {
const {
target, pathRewrite, changeOrigin, secure = true,
target, pathRewrite, changeOrigin = true, secure = true,
} = proxyRule;
const path = rewritePath(ctx.originalUrl, pathRewrite);
const urlObj = new libUrl.URL(path, target);
Expand Down

0 comments on commit 627db59

Please sign in to comment.