3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

react.js リロード(更新) や URL直叩き 時に NOT FOUND を回避する方法

Posted at

課題

react-routerのbrowserHistoryを使っていて、
http://xxxxxx/text/1
みたいなURLを直叩きや、リロードするとNOT FOUND 404エラーになってしまう。

回避策

nginxに、index.htmlにリダイレクトさせる設定を追加すればOK

        location / {
            root /var/webapps/sample/build/;
            index index.html;
            # ↓リダイレクトする設定
            try_files $uri $uri/ /index.html;
        }
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?