-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
378b21c
commit 1945c01
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
const http = require("http"); | ||
const httpProxy = require("http-proxy"); | ||
const proxyApp = httpProxy.createProxyServer({autoRewrite: true}); | ||
const proxyApi = httpProxy.createProxyServer({autoRewrite: true}); | ||
const proxyAuth = httpProxy.createProxyServer({autoRewrite: true}); | ||
|
||
var server = http.createServer(function (req, res) { | ||
|
||
if (req.url.startsWith("/.auth")) { | ||
console.log("auth>", req.method, req.url); | ||
|
||
req.url = `app${req.url}`; | ||
|
||
console.log(req.headers); | ||
proxyAuth.web(req, res, { | ||
target: "http://localhost:4242", | ||
}); | ||
} else if (req.url.startsWith("/api")) { | ||
console.log("api>", req.method, req.url); | ||
|
||
proxyApi.web(req, res, { | ||
target: "http://localhost:7170", | ||
}); | ||
} else { | ||
console.log("app>", req.method, req.url); | ||
|
||
proxyApp.web(req, res, { | ||
target: "http://localhost:4200", | ||
}); | ||
} | ||
}); | ||
|
||
console.log("listening on port 0.0.0.0:80"); | ||
server.listen(80, "0.0.0.0"); |