You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the cloudflare adapters do not serve the static assets correctly if a base path config is set. This is because the adapters look for the filename such that it is the base path + the filename but the SSR manifest only stores the filename without the base path prefix.
Example SSR manifest:
exportconstmanifest=(()=>{function__memo(fn){letvalue;return()=>value??=(value=fn());}return{appDir: "_app",// app path correctly includes the base pathappPath: "base/_app",// the static assets don't have the base path prefixassets: newSet(["favicon.png"]),
Currently the filename is the request URL pathname (which includes the base path). It will never match with the manifest assets if a base is configured. (e.g., base/favicon.png will never map to favicon.png)
This doesn't appear to be fixed. For example, if I set my base to /blog, and then upload to Cloudflare Pages, everything works except anything in the static folder. Everything in static folder is completely inaccessible. The structure of the contents in Cloudflare Pages appears to be correct, the files are there, they are under the subfolder blog, but when I attempt to navigate to them I get a 404. In addition, if I attempt to navigate to them using root, it goes into an infinite refresh loop.
eltigerchino
changed the title
Assets from the static dir are not served if base path is set
Static assets are not served if base path is set
Mar 30, 2024
Making following changes to the generate_manifest/index.js file appears to solve the problem. I've tested these changes locally
// passing base_path as argument to generate_manifest in exports/vite and core/adapt// adding base_path as parameter here// line 22exportfunctiongenerate_manifest({ build_data, relative_path, routes, base_path }){
...
// adding it to the assets path// line 56constassets=build_data.manifest_data.assets.map((asset)=>base_path.slice(1,base_path.length)+"/"+asset.file);
Currently, the cloudflare adapters do not serve the static assets correctly if a
base
path config is set. This is because the adapters look for the filename such that it is the base path + the filename but the SSR manifest only stores the filename without the base path prefix.Example SSR manifest:
Currently the filename is the request URL pathname (which includes the base path). It will never match with the manifest assets if a base is configured. (e.g.,
base/favicon.png
will never map tofavicon.png
)kit/packages/adapter-cloudflare/src/worker.js
Lines 31 to 35 in 3351047
The text was updated successfully, but these errors were encountered: