const e = require('express'); const express = require('express') const request = require('request') const app = express() const port = 8080 // 我自己后端 // 设置跨域访问 app.all('*', (req, res, next) => { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS"); res.header("X-Powered-By",'bmy') res.header("Content-Type", "application/json;charset=utf-8"); next(); }); app.get('/my', (req, res) => { request('http://127.0.0.1:3000/index', function (error, response, body) { console.log('body:', body); // Print the HTML for the Google homepage. res.json(JSON.parse(body)) }); }) app.listen(port, () => console.log(`Example app listening on port ${port}!`))