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

【Vercel】デプロイ後JSが反映されない。

Last updated at Posted at 2024-08-26

こんにちは、無料デプロイツールのVercelを最近使い始めました。
vercelに無事デプロイはできたものの、次はJSファイルが反映されなくなりました。

  • 使用言語
    Laravel
  • 使用ツール
    Vercel
    PostgreSQL

ローカルでは問題なく動くので、「vercel.json」に問題がありそうです。

vercel.jsonの内容

"version": 2,
    "functions": {
        "api/index.php": { 
            "runtime": "vercel-php@0.6.0" 
            } 
        },
    "routes": [
        {
            "src": "/css/(.*)",
            "dest": "/public/css/$1"
        },
        {
            "src": "/js/comment/(.*)",
            "dest": "/public/js/comment/$1"
        },
        {
            "src": "/js/user/(.*)",
            "dest": "/public/js/user/$1"
        },
        {
            "src": "/js/(.*)",
            "dest": "/public/js/$1"
        },
        {
            "src": "/images/(.*)",
            "dest": "/public/images/$1"
        },
        {
            "src": "/post/(.*)",
            "dest": "/public/post/$1"
        },
        {
            "src": "/profile/(.*)",
            "dest": "/public/profile/$1"
        },
        {
            "src": "/(.*)",
            "dest": "/api/index.php" 
        }

力を貸していただけると幸いです。

【解決】
相対パスの使用で反映された

<script src="/js/app.js"></script>

を下のように変える

<script src="/js/comment/app.js"></script>
1
0
2

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?