LoginSignup
0
1

More than 1 year has passed since last update.

Reactで直接URLを入れると404エラーになる時の対処法

Last updated at Posted at 2022-01-21

この記事を書こうと思った理由

reactで直接URLを叩くと404エラーになるという記事は多数見たのですが、わかりやすく解決法が書かれている記事が少なかったので書くことにしました。

結論:解決策

index.htmlに <head> を作り、中に<base href="/" >と入れる。

こんな感じ

index.html
<head>
<base href="/" >
</head>

注意点

<link rel="stylesheet">等のリンクを貼りたいときは<base href="/" >
より下に書かないといけないらしいです。

感想

いろんな記事を見ましたがこれが一番簡単な解決策でした。
一人でも多くの方の役に立てれば幸いです。

0
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
0
1