-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby): Refactor partytown local proxy logic
- Loading branch information
Showing
4 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import proxy from "express-http-proxy" | ||
import type { RequestHandler } from "express" | ||
|
||
export const partytownProxyPath = `/__partytown-proxy` | ||
|
||
export function partytownProxy( | ||
partytownProxiedURLs: Array<string> | ||
): RequestHandler { | ||
return proxy(req => new URL(req.query.url as string).host as string, { | ||
filter: req => partytownProxiedURLs.some(url => req.query?.url === url), | ||
proxyReqPathResolver: req => { | ||
const { pathname = ``, search = `` } = new URL(req.query?.url as string) | ||
return pathname + search | ||
}, | ||
}) | ||
} |