Skip to content
Snippets Groups Projects
Commit 77f7c677 authored by Falk's avatar Falk :ping_pong:
Browse files

feature: allow CORS from freefalk.tk domain

parent f75fb9df
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,20 @@ let cookieParser = require('cookie-parser');
const app = express();
const port = process.env.PORT || 3002;
const whitelist = [`http://localhost:${ port }`, `http://freefalk.tk`]
const corsOptions = {
origin: `http://localhost:${ port }`,
credentials: true
credentials: true,
origin: function(origin, callback){
// allow requests with no origin
if(!origin) return callback(null, true);
if(whitelist.indexOf(origin) === -1){
var message = "The CORS policy for this origin doesn't " +
"allow access from the particular origin.";
return callback(new Error(message), false);
}
return callback(null, true);
}
};
app.use(express.json());
......@@ -48,7 +59,7 @@ app.use(errorRoutes);
try{
await new Promise( (__ful, rej__ )=>{
app.listen(port, function(){
console.log( `ToDo server is up on port ${ port }`);
console.log(`todo-app-backend is up on port ${ port }`);
__ful();
}).on( 'error', rej__);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment