简体   繁体   中英

get error invalid host header when upload React code in Heroku

I get the error invalid host header I don't know the reason please if anyone can help

.env

HOST=herokuapp.com

server.js

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

app.use(express.static(path.join(__dirname, 'build')));

app.get('*', function (req, res) {
    res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(process.env.PORT);

package.json

"proxy": "http://localhost:5000",

when write Heroku log in console return this if it will help you to find any solution and thanks all for trying

app[web.1]: Attempting to bind to HOST environment variable: herokuapp.com
app[web.1]: If this was unintentional, check that you haven't mistakenly set it in your shell.
app[web.1]: Learn more here: https://cra.link/advanced-config
app[web.1]:
app[web.1]: Could not find an open port at herokuapp.com.
app[web.1]: Network error message: listen EADDRNOTAVAIL: address not available 3.218.84.197
app[web.1]:
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `npm start`
app[web.1]:
app[web.1]: > client@0.1.0 start
app[web.1]: > react-scripts start
app[web.1]:
app[web.1]: Attempting to bind to HOST environment variable: herokuapp.com
app[web.1]: If this was unintentional, check that you haven't mistakenly set it in your shell.
app[web.1]: Learn more here: https://cra.link/advanced-config
app[web.1]:
app[web.1]: Could not find an open port at herokuapp.com.
app[web.1]: Network error message: listen EADDRNOTAVAIL: address not available 23.21.41.134
app[web.1]:
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ahmed-radi-bank-system.herokuapp.com request_id=1fe76374-c2b2-4742-8274-ac29595f176b fwd="156.222.196.219" dyno= connect= service= status=503 bytes= protocol=https
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ahmed-radi-bank-system.herokuapp.com request_id=729f1256-9d7e-4cfa-83e7-0fcb59b886a2 fwd="156.222.196.219" dyno= connect=
service= status=503 bytes= protocol=https
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ahmed-radi-bank-system.herokuapp.com request_id=7cea8936-c5d5-4171-9c79-e6795e805cc9 fwd="156.222.196.219" dyno= connect= service= status=503 bytes= protocol=https
heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ahmed-radi-bank-system.herokuapp.com request_id=581a5de7-c23d-496e-a27f-5ade070cc55b fwd="156.222.196.219" dyno= connect=
service= status=503 bytes= protocol=https

I will upload my project on Netify

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM