LoginSignup
1
0

More than 1 year has passed since last update.

[Netlify] Reactで直接URLを叩くと404になるときの対応

Posted at

概要

以下の記事の解決方法に、サーバー側の設定でリライト設定をするとあり、
Netlifyを使っていて少し手間取ったため、Netlifyで対応する方法を書いておきます。

状況(上の記事から引用)

https://hogeapp.com/Fugaが表示された後リロードする → 404ページが表示される
ブラウザでhttps://hogeapp.com/Fugaを直接叩く → 404ページが表示される

やること

  • _redirectsファイルをメインのディレクトリに作成
  • 以下の内容を記述
_redirects
/*    /index.html   200

これでNetlifyの方でデプロイしたら完了です。

参考

Special Thanks;
https://qiita.com/yakipudding/items/78e68ef31e55f559c0dc

https://docs.netlify.com/routing/redirects/rewrites-proxies/
https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0