Skip to content

Commit 86e539e

Browse files
authored
fix: notify activity dev server and double encoding when proxying to preview server (#7300)
1 parent b4c6ca6 commit 86e539e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/utils/proxy.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ const serveRedirect = async function ({
365365
(await isEndpointExists(decodeURIComponent(reqUrl.pathname), options.target))
366366
if (staticFile || endpointExists) {
367367
const pathname = staticFile || reqUrl.pathname
368-
req.url = encodeURI(pathname) + reqUrl.search
368+
req.url = encodeURI(decodeURI(pathname)) + reqUrl.search
369369
// if there is an existing static file and it is not a forced redirect, return the file
370370
if (!match.force) {
371371
return proxy.web(req, res, { ...options, staticFile })
@@ -858,7 +858,17 @@ const onRequest = async (
858858
},
859859
}
860860

861+
const maybeNotifyActivity = () => {
862+
if (req.method === 'GET' && api && process.env.NETLIFY_DEV_SERVER_ID) {
863+
notifyActivity(api, siteInfo.id, process.env.NETLIFY_DEV_SERVER_ID)
864+
}
865+
}
866+
861867
if (match) {
868+
if (!isExternal(match)) {
869+
maybeNotifyActivity()
870+
}
871+
862872
// We don't want to generate an ETag for 3xx redirects.
863873
// @ts-expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message
864874
req[shouldGenerateETag] = ({ statusCode }) => statusCode < 300 || statusCode >= 400
@@ -886,9 +896,7 @@ const onRequest = async (
886896
return proxy.web(req, res, { target: functionsServer })
887897
}
888898

889-
if (req.method === 'GET' && api && process.env.NETLIFY_DEV_SERVER_ID) {
890-
notifyActivity(api, siteInfo.id, process.env.NETLIFY_DEV_SERVER_ID)
891-
}
899+
maybeNotifyActivity()
892900

893901
proxy.web(req, res, options)
894902
}

0 commit comments

Comments
 (0)