我尝试了所有可能的解决方案,我也编译了与Flutter Web(Flutter gallery和其他)的repos,无论默认的演示主页显示什么。我想它可能与nginx配置有关,但我不确定它可能是什么。
我正在将build/web
复制到服务器。
下面是我的Flutter代码:
第一个
下面是我的nginx配置:
# ssl
ssl_certificate /etc/nginx/certificate/nginx-certificate.crt; ssl_certificate_key /etc/nginx/certificate/nginx.key;
# api backend
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name testpage.net;
location /api {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers
'DNT,X-Mx-ReqToken,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass_header Set-Cookie;
proxy_read_timeout 900;
proxy_buffers 32 4k;
proxy_pass http://127.0.0.1:6969/;
}
location / {
# based on internet this should be no cache options
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
root /home/testpage/www/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
这看起来很奇怪,如果我用任何东西替换index.html,它都能正常工作。我在本地调试它,没有留下任何残留文件,每次更新我都在清理它。但无论我做什么,我仍然看到这样的情况:
1条答案
按热度按时间yxyvkwin1#
所以问题很简单,我是通过输入
page.com/
访问网页的,而不仅仅是page.com
因此,问题是写额外的
/
。这真的是一个简单的解决方案混淆的情况。不知道错误来自哪里,如果它是nginx发送给我一些缓存的网站或Flutter本身,但我希望更好地解释错误。在浏览器控制台中没有任何东西,这将表明这个严重的问题。