-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
21 lines (18 loc) · 742 Bytes
/
app.js
File metadata and controls
21 lines (18 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const path= require('path');
const publicPath = path.join(__dirname,'../public');
const express=require('express');
const app=express();
const bodyParser=require('body-parser');
const router=require('./routes/questionRoutes');
app.use(bodyParser.urlencoded({extended : true}));
app.use(bodyParser.json());
app.use(express.static(publicPath));
app.use(function(req,res,next){
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Expose-Headers', 'x-auth');
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE");
res.setHeader('Access-Control-Allow-Headers','Origin, X-Requested-With,content-type, Accept , x-auth');
next();
});
app.use('/api/question',router);
module.exports=app;