react nodejs router express周り


const express = require("express");
const path = require('path');
const app  = express();
const port = 80;

app.use('/', express.static(path.join(__dirname, 'build')));
// HTTPサーバを起動する
app.listen(port, () => {
 // console.log(`listening at http://localhost:${port}`);
});


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

この一行の設定だけだとルートでの更新は大丈夫だけど、ルートではない

https://app.com/xxx

などで更新押すとCannot GET /xxxとなる。

ルーティングを以下のようにすることによってreact routerなどで設定したパスでの更新でCannot GET /xxxが出なくなる。

ここから先は

360字

¥ 300

この記事が気に入ったらサポートをしてみませんか?