You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
641 B
26 lines
641 B
// [START functions import]
|
|
const express = require('express');
|
|
const serverLess = require('serverless-http');
|
|
|
|
const matchMock = require('./mock/matchMock');
|
|
|
|
const app = express();
|
|
|
|
app.all('*', (req, res, next) => {
|
|
res.header('Access-Control-Allow-Origin', '*');
|
|
res.header(
|
|
'Access-Control-Allow-Headers',
|
|
'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild',
|
|
);
|
|
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
|
|
|
|
if (req.method == 'OPTIONS') {
|
|
res.send(200);
|
|
} else {
|
|
next();
|
|
}
|
|
});
|
|
|
|
app.use(matchMock);
|
|
|
|
exports.handler = serverLess(app);
|
|
|