部署到heroku服务器

时间:2019-06-03 16:20:29

标签: javascript reactjs express heroku deployment

我已经在express的heroku上部署了react应用。而且我在控制台中收到此错误:拒绝加载图像“ https://sporthelper.herokuapp.com/favicon.ico”,因为它违反了以下内容安全策略指令:“ default-src'none'”。请注意,未明确设置“ img-src”,因此将“ default-src”用作备用。

这是heroku部署的链接https://sporthelper.herokuapp.com/

我试图在myapp / public / index.html中更改元标记,但这无济于事。

这是我的快递服务器

dout = {'param1': [[1, 3, 5], [1, 2], [7, 8, 9, 10]], 'param2': [[3, 1, 2], [2, 1], [4, 3, 2, 1]]}

这是来自我服务器的package.json


const express = require('express');
const path = require('path');
const app = express();

app.use(express.static('sport_app/build'));

app.get('/*', (req, res) => {
  res.sendFile(path.resolve(__dirname, 'sport_app', 'build', 'index.html'));
});

const port = process.env.PORT || 5000;
app.listen(port);

1 个答案:

答案 0 :(得分:0)

使用npm软件包serve而不是server.js脚本解决了该问题。 我将以下行添加到package.json脚本中 "start": "serve -s dist",