main.js 917 B

1234567891011121314151617181920212223242526
  1. const express = require('express')
  2. const bodyParser = require('body-parser')
  3. const app = express()
  4. const sendemail = require('./sendemail')
  5. const verification = require('./verification')
  6. app.all('*', (req, res, next) => {
  7. res.header("Access-Control-Allow-Origin", req.headers.origin); //设置来源
  8. res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  9. res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  10. res.header("Access-Control-Max-Age", "604800000");
  11. res.header("Access-Control-Allow-Credentials", true);
  12. res.header("X-Powered-By", ' 3.2.1');
  13. // res.header("Content-Type", "application/json;charset=utf-8");
  14. next();
  15. });
  16. app.use(bodyParser.urlencoded({extended:false}))
  17. app.use('/postemail', sendemail)
  18. app.use('/verification', verification)
  19. app.listen('8081', () => {
  20. console.log('http://127.0.0.1:8081')
  21. })