Skip to content
Snippets Groups Projects
Commit e62eede6 authored by Moreau Elise's avatar Moreau Elise
Browse files

[cors] package : use express cors to allow access

parent 3e036d57
Branches
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"description": "A simple chat", "description": "A simple chat",
"dependencies": { "dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1", "express": "^4.17.1",
"express-joi-validation": "^5.0.0", "express-joi-validation": "^5.0.0",
"express-jwt": "^6.0.0", "express-jwt": "^6.0.0",
... ...
......
import express from 'express' import express from 'express'
import cors from 'cors'
import * as http from 'http' import * as http from 'http'
import mongoose from "mongoose"; import mongoose from "mongoose";
import WebSocket from 'ws' import WebSocket from 'ws'
...@@ -33,12 +34,7 @@ wss.on('connection', function (ws) { ...@@ -33,12 +34,7 @@ wss.on('connection', function (ws) {
app.use(express.json()); app.use(express.json());
app.use(function(req, res, next) { app.use(cors());
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "*");
res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE");
next();
});
app.get('/', function (req, res) { app.get('/', function (req, res) {
// res.send('OK') // res.send('OK')
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment