第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

heroku 部署后,似乎找不到我的 react 應(yīng)用程序文件:GET / 404

heroku 部署后,似乎找不到我的 react 應(yīng)用程序文件:GET / 404

蕪湖不蕪 2021-09-30 17:31:04
我分別構(gòu)建了兩個(gè)應(yīng)用程序:一個(gè) React 應(yīng)用程序客戶端和 API rest with node 和 express在遵循許多教程之后,我總是發(fā)現(xiàn)一些問(wèn)題??雌饋?lái)我在兩個(gè)應(yīng)用程序之間都沒(méi)有連接,它似乎不是我的代碼中的 index.html 文件。我的package.json 中有這個(gè)  "scripts": {    "start": "react-app-rewired start",    "build-dev": "dotenv -e .env.development react-app-rewired build",    "build-prod": "dotenv -e .env.production react-app-rewired build",    "build": "react-app-rewired build",    "test": "react-app-rewired test --env=jsdom",    "eject": "react-app-rewired eject"  }我做了 npm run build 并將這些文件復(fù)制到我的 API(服務(wù)器端)中的 public/ 文件夾我已經(jīng)將app.js 中的這一行更改為:app.use(express.static(path.join(__dirname, 'public/index.html')));在我的 api(服務(wù)器端)的公共文件夾中,我粘貼了來(lái)自 npm run build(客戶端應(yīng)用程序)的所有內(nèi)容,甚至是 index.html。該文件的完整內(nèi)容是:<!doctype html><html><head><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/><script src="https://as.alipayobjects.com/g/component/fastclick/1.0.6/fastclick.js"></script><script>"addEventListener"in document&&document.addEventListener("DOMContentLoaded",function(){FastClick.attach(document.body)},!1),window.Promise||document.writeln('<script src="https://as.alipayobjects.com/g/component/es6-promise/3.2.2/es6-promise.min.js"><\/script>')</script><title>A-Web</title><link href="/static/css/2.393a28fb.chunk.css" rel="stylesheet"><link href="/static/css/main.969b3049.chunk.css" rel="stylesheet"></head><body><div id="root">當(dāng)我打開(kāi) heroku 時(shí),控制臺(tái)顯示我:Failed to load resource: the server responded with a status of 404 (Not Found){message: "Not Found"}我只需要上傳到 heroku 即可獲得生產(chǎn)環(huán)境。似乎一切都是正確的,我嘗試了很多教程,但對(duì)我來(lái)說(shuō)沒(méi)有任何效果。我的github:https://github.com/titoih/a-webhttps://github.com/titoih/a-apiPD:我正在使用 AntDesign。
查看完整描述

3 回答

?
紅糖糍粑

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超6個(gè)贊

我在 server.js 中用這段代碼調(diào)試了它


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


app.get('*', function(req, res) {

  res.sendFile(path.join(__dirname, '/client/build', 'index.html'))

})

我從客戶端文件夾中的 .gitignore 中刪除了構(gòu)建文件夾。當(dāng)您在默認(rèn)構(gòu)建文件夾中使用 create react app 時(shí),在 .gitignore 中。請(qǐng)記住在部署之前進(jìn)行全新構(gòu)建。


查看完整回答
反對(duì) 回復(fù) 2021-09-30
?
湖上湖

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個(gè)贊

我得到了相同的“404 找不到請(qǐng)求的路徑”并通過(guò)從 .gitignore 中刪除構(gòu)建來(lái)解決它


查看完整回答
反對(duì) 回復(fù) 2021-09-30
?
慕森卡

TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊

最后,我這樣做了:


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


app.get('*', function(req, res) {

  res.sendFile(path.join(__dirname, 'public', 'index.html'));

});

幸運(yùn)的是,heroku 應(yīng)用程序是在線的...


但是,我在瀏覽它時(shí)遇到了幾個(gè)問(wèn)題。



查看完整回答
反對(duì) 回復(fù) 2021-09-30
  • 3 回答
  • 0 關(guān)注
  • 214 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)