我在Laravel 5.4
上使用Vue.js
和LEMP Stack 16.04
。我的网站使用的是Let's encrypt
证书。
我的资产是使用Laravel Mix
编译并插入我的应用程序
<script src="{{mix("/js/manifest.js")}}"></script>
<script src={{mix("/js/vendor.js")}}></script>
<script src="{{ mix('/js/app.js') }}"></script>
当我转到https://example.com
拒绝执行“https://example.com/js/app.6fb8b055657fe5daae8f.js”脚本,因为其MIME类型(“text / html”)不可执行,并且启用了严格的MIME类型检查。
文件app.6fb8b055657fe5daae8f.js
类型为text/html
,但还有另一个调用,其发起人为app.6fb8b055657fe5daae8f.js
,其类型为script
。不知道这是否正常
普通的MIME类型是否被识别为text/html
,而它是我的app.js
文件?
我能做些什么才能让它发挥作用?问题是nginx
或laravel
还是`SSL证书?
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --add-module=/home/leo/ngx_brotli --sbin-path=/usr/sbin/nginx --add-module=/home/leo/ngx_pagespeed-1.12.34.2-beta --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
#server {
# server_name ~^(.*)\.example\.com$ ;
#root www/laravel/public ;
#}
server {
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
root /var/www/laravel/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name example.com *.example.com www.example.com ;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.well-known {
allow all;
}
}
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/ja$
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
............
............
}
答案 0 :(得分:1)
首先检查您的代码。
<script src="{{mix("/js/manifest.js")}}"></script>
<script src={{mix("/js/vendor.js")}}></script>
<script src="{{ mix('/js/app.js') }}"></script>
在你的问题中甚至突出显示,现在检查一下:
<script src="{{ mix('/js/manifest.js') }}"></script>
<script src="{{ mix('/js/vendor.js') }}"></script>
<script src="{{ mix('/js/app.js') }}"></script>
看看这是否有帮助。