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 3 years have passed since last update.

「Uncaught SyntaxError: Unexpected token '<'」Next.jsとNuxt.jsを同じドメインでデプロイ後にハマったこと

Last updated at Posted at 2022-02-28

状況

ECSでのデプロイ
SPAのNuxt.jsのアプリが元からあり、SSRのNext.jsを同じドメインでホスティングする。

デプロイ時の問題

Next.jsのJSとImageが反映されていなかった
Uncaught SyntaxError: Unexpected token '<'のエラーが出ていた。

結論

ALBでJSのパスとImageのパスを指定しないとJSのファイルとImageを読み込んでくれない。
元からあるNuxt.jsを呼んでしまう。
ALBの設定↓↓↓

ルール___EC2_Management_Console.png

調べかた

検証でElementを確認。headの中を見る。

<script src="/_next/static/chunks/pages/history/list-xxxxxxxx.js" defer=""></script>

URLが https://sample.com/history/1 であれば、
https://sample.com/_next/static/chunks/pages/history/list-xxxxxxxx.jsでjsファイルが表示されていなければ、パスが通っていない。

感想

検索するとjsのミスで出るエラーという記事が多いが、こんなこともある。次からは自分で解決できるようになりたい。

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?