我在React中有一个Application构建,而Server在Heroku平台上的Express.js中是以下应用程序 http://duberex.herokuapp.com/ 输入有效的邮政编码,如99201
这是server.js代码 var express = require('express');
// Create our app
var app = express();
const PORT = process.env.PORT || 3000;
app.use(function (req, res, next){
res.header('Access-Control-Allow-Origin', '*');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
if (req.headers['x-forwarded-proto'] === 'https') {
res.redirect('http://' + req.hostname + req.url);
next();
} else {
next();
}
});
app.use(express.static('public'));
app.listen(PORT, function () {
console.log('Express server is up on port ' + PORT);
});