| 1234567891011121314151617181920 |
- import express from 'express';
- import bodyParser from 'body-parser';
- import cors from 'cors';
- const app = express();
- const whitelist = ['http://localhost:8000'];
- const corsOptions = {
- origin: (origin, callback) => {
- if (whitelist.indexOf(origin) !== -1) {
- callback(null, true)
- } else {
- callback(new Error('Not allowed by CORS'))
- }
- }
- };
- app.use(cors(corsOptions));
- app.use(express.static('public'));
- app.listen(5000);
|