Skip to content

Commit

Permalink
feat: proxify .auth/api/app routes
Browse files Browse the repository at this point in the history
  • Loading branch information
manekinekko committed Jun 30, 2020
1 parent 378b21c commit 1945c01
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"azure-functions-core-tools": "^2.7.2508",
"cookie": "^0.4.1",
"http-proxy": "^1.18.1",
"jsonwebtoken": "^8.5.1",
"node-fetch": "^2.6.0"
}
Expand Down
34 changes: 34 additions & 0 deletions proxy.js
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");

0 comments on commit 1945c01

Please sign in to comment.