<base href>
issue minimal reproduction
This site has a <link rel="modulepreload">
element in its <head>
element.
Instructing to preload the module.js
file. Given the <base href="/">
element, the
browser properly preloads /module.js
file. And not /subdir/module.js
Thanks to
Automatic Link
header generation, Cloudflare servers respond with
Link
response headers
when serving this page after reading those. So the file can be preloaded earlier.
However, the generated Link
response header does not take into account the
<base href="/">
element. And the preloaded file is /subdir/module.js
.
Which doesn't exist. Seems that <base>
element is not taken into account to resolve links and
later generate the Link
header with them. But it should. In order to properly generate the
automatic Link
headers. Then, the browser preloads the proper one when reaching the
<link>
element.
Inspect the network requests to check that /subdir/module.js
is wrongfully being preloaded.
Beware that the response will be 200 OK
and not 404 Not found
. Given that
Cloudflare Pages matches all incoming paths to the root (/
)
to allow single-page applications (SPA) capture and process all routes.