pas94
CDCloudflare Developers
•Created by DeltaOne on 10/29/2024 in #workers-help
Nested directories are not working in Static Assets
@texan anyone from the cloudflare team that can address this?
68 replies
CDCloudflare Developers
•Created by DeltaOne on 10/29/2024 in #workers-help
Nested directories are not working in Static Assets
@texan any updates on this
68 replies
CDCloudflare Developers
•Created by DeltaOne on 10/29/2024 in #workers-help
Nested directories are not working in Static Assets
@KingsLayer @Will Taylor | Workers wragnler dev doesn't work for the nested routes, (css/styles.css and scripts/index.js) if I take them out to the folder above them, which is "public" folder, it works, index.html gets fetched properly because its in the public folder, there must be something going on, @KingsLayer let me know if you found a solution
68 replies
CDCloudflare Developers
•Created by DeltaOne on 10/29/2024 in #workers-help
Nested directories are not working in Static Assets
here is the structure I have
=== wrangler.toml ===
name = "test-app"
main = "server/index.js"
compatibility_date = "2024-10-11"
compatibility_flags = ["nodejs_compat"]
workers_dev = true
account_id = "..."
assets = { directory = "./server/public/", binding = "ASSETS", html_handling = "force-trailing-slash", not_found_handling = "single-page-application" }
=== folder structure ===
root-app-folder
server/
public/
css/
styles.css
scripts/
auth.js
index.js
index.html
index.js
package.json
wrangler.toml
=== server/index.js ===
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname.startsWith("/api/")) {
// TODO: Add your custom /api/* logic here.
return new Response("Ok");
}
// Passes the incoming request through to the assets binding.
// No asset matched this request, so this will evaluate
not_found_handling
behavior.
console.log('request.url', request.url)
return env.ASSETS.fetch(request);
},
};
=== server/public/index.html ===
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Awesome Website Landing Page</title>
<link rel="stylesheet" href="/css/styles.css">
</head>
<body>
...
<script type="module" src="/scripts/index.js"></script>
</body>
</html>68 replies
CDCloudflare Developers
•Created by DeltaOne on 10/29/2024 in #workers-help
Nested directories are not working in Static Assets
@Will Taylor | Workers @KingsLayer I'm experiencing the same issue, if there is a nested folder for the static assets, it won't load the static files
68 replies