Livewire 未定義
P粉450744515
P粉450744515 2023-11-09 15:34:23
0
1
757

我在將 Laravel Livewire 專案部署到伺服器時遇到問題。問題是 livewire.js 檔案無法存取並在控制台中顯示錯誤

Livewire is not defined

我的伺服器環境是LNMP。我正在使用 Nginx 而不是 apache。還有另一種方法可以解決此問題,即發布 livewire,將檔案從供應商資料夾複製到資源資料夾。之後你必須自己維護 js 文件,而我不想這樣做。 可能是Nginx阻塞了js回應檔導致的,如何解決這個問題

這是我的 nginx 設定檔

user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
#AAPANEL_FASTCGI_CONF_BEGIN
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_path /dev/shm/nginx-cache/wp levels=1:2 keys_zone=WORDPRESS:100m inactive=60m max_size=1g;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
#AAPANEL_FASTCGI_CONF_END

        include       mime.types;
        #include luawaf.conf;

        include proxy.conf;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 60;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length  1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6].";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
        limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;

server
    {
        l isten 888;
        server_name phpmyadmin;
        index index.html index.htm index.php;
        root  /www/server/phpmyadmin;
            location ~ /tmp/ {
                return 403;
            }

        #error_page   404   /404.html;
        include enable-php.conf;

        location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
include /www/server/panel/vhost/nginx/*.conf;
}


#
P粉450744515
P粉450744515

全部回覆(1)
P粉237647645

livewire.js 不會發生太大變化,除非composer.json 中有關 laravel-livewire 套件的更改,我建議您只使用發布 livewire.js 檔案

然後新增自動發布腳本

{
"scripts": {
    "post-autoload-dump": [
        "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover --ansi",
        "@php artisan vendor:publish --force --tag=livewire:assets --ansi"
    ]
}
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板