Created
February 20, 2021 20:52
-
-
Save mxro/cb7c1264cf66c4e310e56f693d98ad9c to your computer and use it in GitHub Desktop.
A simple Express.js server
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
import express from 'express'; | |
import cors from 'cors'; | |
import helmet from 'helmet'; | |
import { rootHandler } from './root'; | |
export const app: express.Application = express(); | |
app.use(helmet()); | |
if (process.env.CORS) { | |
console.info(`Starting server with CORS domain: ${process.env.CORS}`); | |
app.use(cors({ origin: process.env.CORS, credentials: true })); | |
} | |
app.use(express.json()); | |
app.get('/', rootHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment