-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit d24910b
Showing
4 changed files
with
1,330 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
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,39 @@ | ||
const express = require("express"); | ||
const morgan = require("morgan"); | ||
const consola = require("consola"); | ||
const history = require('connect-history-api-fallback'); | ||
const { createProxyMiddleware } = require("http-proxy-middleware"); | ||
|
||
const app = express(); | ||
|
||
app.set("trust proxy", "loopback"); | ||
app.use(morgan("combined")); | ||
|
||
app.use("/healthcheck/", (_, res) => res.send("OK")); | ||
|
||
const target = process.env.BACKEND_URL || "https://app.tough-dev.school"; | ||
|
||
app.use( | ||
["/admin", "/api", "/static"], | ||
createProxyMiddleware({ | ||
target, | ||
changeOrigin: Boolean(target.includes("https")), | ||
}) | ||
); | ||
|
||
const staticFolder = process.env.STATIC_FOLDER || '/dist'; | ||
|
||
consola.info(`Serving static from ${staticFolder}`); | ||
app.use(history()); | ||
app.use(express.static(staticFolder)) | ||
|
||
/* Run express */ | ||
const host = process.env.HOST || '0.0.0.0'; | ||
const port = process.env.PORT || 3000; | ||
app.set('port', port); | ||
app.listen(port, host); | ||
|
||
consola.ready({ | ||
message: `Server listening on http://${host}:${port}`, | ||
badge: true, | ||
}); |
Oops, something went wrong.