Skip to content

Instantly share code, notes, and snippets.

@odedw
Last active January 3, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odedw/b7684cebb409165e5e227ac10ef82ebe to your computer and use it in GitHub Desktop.
Save odedw/b7684cebb409165e5e227ac10ef82ebe to your computer and use it in GitHub Desktop.
Reverse Proxy
function handleRequest(request) {
const firstSegment = getFirstSegmentOfPath(request);
const destinationApp = config.apps.find((app) => firstSegment === app.path);
if (destinationApp) {
proxyRequestToDomain(destinationApp.domain);
return;
}
proxyRequestToApp(config.defaultDomain);
}
type App = {
path: string;
targetDomain: string;
};
type Config = {
defaultDomain: string;
apps: App[];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment