Skip to content

Commit

Permalink
fix: not support trailing slash
Browse files Browse the repository at this point in the history
closes #19
  • Loading branch information
zce committed Jun 28, 2019
1 parent 759a057 commit 2e6fd81
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ const proxy = httpProxy.createProxyServer({

proxy.on('proxyReq', (proxyReq, req, res, options) => {
// append apikey
const { query, pathname } = url.parse(proxyReq.path, true, true)
let { query, pathname } = url.parse(proxyReq.path, true, true)
query.apikey = query.apikey || process.env.API_KEY
// trim trailing slash #19
pathname = pathname.replace(/\/$/, '')
proxyReq.path = url.format({ query, pathname })

// change referer
Expand Down

1 comment on commit 2e6fd81

@vercel
Copy link

@vercel vercel bot commented on 2e6fd81 Jun 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.