Skip to content

Commit

Permalink
Dev: Pass query prams to rewrites
Browse files Browse the repository at this point in the history
Fixes: #691
  • Loading branch information
RaeesBhatti committed Feb 1, 2020
1 parent 615fed1 commit 91fa2fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/commands/dev/index.js
@@ -1,4 +1,5 @@
const url = require('url')
const { URLSearchParams } = require('url')
const path = require('path')
const fs = require('fs')
const { flags } = require('@oclif/command')
Expand Down Expand Up @@ -275,7 +276,9 @@ function serveRedirect(req, res, proxy, match, options) {
return handler(req, res, {})
}

req.url = dest.pathname + dest.search
const urlParams = new URLSearchParams(reqUrl.searchParams)
dest.searchParams.forEach((val, key) => urlParams.set(key, val))
req.url = dest.pathname + (urlParams.toString() && '?' + urlParams.toString())
console.log(`${NETLIFYDEVLOG} Rewrote URL to `, req.url)

if (isFunction({ functionsPort: options.functionsPort }, req)) {
Expand Down

0 comments on commit 91fa2fa

Please sign in to comment.