0
0

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 1 year has passed since last update.

【React】Uncaught runtime errors: × ERROR Network Error AxiosError: Network Error at XMLHttpRequest.handleError の解決方法

Last updated at Posted at 2023-05-19

Rails + React で教材を参考にSPA化構成のアプリを開発中、以下のエラーに遭遇しました。

Uncaught runtime errors:
ERROR
Network Error
AxiosError: Network Error
    at XMLHttpRequest.handleError (http://localhost:3000/static/js/bundle.js:48052:14)
ERROR
Network Error
AxiosError: Network Error
    at XMLHttpRequest.handleError (http://localhost:3000/static/js/bundle.js:48052:14)

image.png

結論

以下のように環境変数でURLをIPアドレスで表示するとエラーがなくなりました。原因はよくわかっていませんが。

before

frontend/.env
REACT_APP_API_DOMEIN=http://localhost:3030

after

frontend/.env
REACT_APP_API_DOMEIN=http://10.0.2.2:3030

このように書き換えて、yarn startを一旦停止して再起動すると
image.png

きちんと表示されました🙌

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?