Skip to content

Instantly share code, notes, and snippets.

@mxro

mxro/server.ts

Created Feb 20, 2021
Embed
What would you like to do?
A simple Express.js server
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