"Loading failed for the <script>" 404 错误 - 苗条

"Loading failed for the <script>" 404 Error - Svelte

我在使用 Svelte 时遇到错误,无法在 GitHub 上托管的网站上加载 bundle.jsbundle.cssglobal.cssfavicon.png页数。

我已经通读 this question 但问题在其他浏览器上仍然存在,没有任何 VPN、干净的 Firefox 配置文件或没有扩展,并且似乎是接受 content-type 的问题的文件。

Firefox 控制台中的错误消息是:

GET https://path/to/global.css    [HTTP/2 404 Not Found 9ms]

GET  https://path/to/bundle.css   [HTTP/2 404 Not Found 9ms]

GET https://path/to/bundle.js     [HTTP/2 404 Not Found 7ms]

Loading failed for the <script> with source “https://path/to/bundle.js”

GET https://path/to/favicon.png   [HTTP/2 404 Not Found 7ms]

以及“网络”选项卡 returns:

对于 favicon.png 的响应和请求 headers:

// Request

GET /favicon.png HTTP/2
Host: kitchefs.github.io
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0
Accept: image/webp,*/*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Referer: https://kitchefs.github.io/beta/
TE: Trailers

// Response

HTTP/2 404 Not Found
content-type: text/html; charset=utf-8
server: GitHub.com
strict-transport-security: max-age=31556952
etag: W/"5f4de496-313"
access-control-allow-origin: *
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: EAA2:03EC:1BFD04:221937:5F816340
accept-ranges: bytes
date: Sat, 10 Oct 2020 07:39:07 GMT
via: 1.1 varnish
age: 475

其他回复 headers 都显示 content-type 类型的 text/html,尽管他们都不接受 text/html

我在 gh-pages 分支上使用 GitHub 页面,我可以确认这些文件存在。如果这是 GitHub 页面或 Svelte 的问题,我正在措辞,我可以做些什么来 fix/prevent 这个问题在未来发生。

如果需要,这里是the code and the website can be accessed at https://kitchefs.github.io/beta

删除 public/index 中的前导 /。html:

<link rel='icon' type='image/png' href='favicon.png'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='build/bundle.css'>
<script defer src='build/bundle.js'></script>

Gh-pages 将使用您在 URL 中的存储库名称进行解析。因此你不在基本路径上。

https://kitchefs.github.io/beta/