Open1
Express すべてのリクエストを処理する
reactをdeployする環境におけるexpressの設定
404 対策?
これまでは
app.get('/*', (req, res) => {
res.sendFile(path.join(__dirname, "..", "build", "index.html"));
});
c:\Users\express\node_modules\path-to-regexp\dist\index.js:73
throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
^
TypeError: Missing parameter name at 2: https://git.new/pathToRegexpError
最近は(2025/4)
app.get(/.*/, (req, res) => {
res.sendFile(path.join(__dirname, "..", "build", "index.html"));
});
こんな感じ
ログインするとコメントできます