Silabear
Silabear
CDCloudflare Developers
Created by Silabear on 12/17/2023 in #workers-help
Caching literally not working
I'm trying to create a file script which caches all files for 30 seconds. However, it never caches it, or at least it never gets it from the cache. Every time it's a cache miss. I've been trying to fix this for a while now and have gotten nowhere. Can someone have a look to see if the issue is obvious? https://sourceb.in/HZVNZhS2eo
7 replies
CDCloudflare Developers
Created by Silabear on 5/9/2023 in #workers-help
Uncaught (in promise) error
Hey, I'm tryna make a file uploading system. My full code is https://pastebin.com/dUCApxp4, but this should be the important part:
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1);

const { pathname } = new URL(request.url);
if(pathname == "/") {
return new Response("CDN is working! :D")
}

switch (request.method) {
case 'PUT':
if(request.headers["Authorization"] != "nop!") return "no, go away"
await env.data.put(key, request.body, {
customMetadata: Record({"uploader":request.headers["Author"]})
});
return "helo mate"
...
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1);

const { pathname } = new URL(request.url);
if(pathname == "/") {
return new Response("CDN is working! :D")
}

switch (request.method) {
case 'PUT':
if(request.headers["Authorization"] != "nop!") return "no, go away"
await env.data.put(key, request.body, {
customMetadata: Record({"uploader":request.headers["Author"]})
});
return "helo mate"
...
However, when I sent a PUT request with the valid headers and data, it returns 500, and the logs show Uncaught (in promise) TypeError: Incorrect type for Promise: the Promise did not resolve to 'Response'.. I've been trying to fix this for a very long time, so any help would be appreciated!
19 replies
CDCloudflare Developers
Created by Silabear on 3/5/2023 in #pages-help
Trying to fetch() with Svelte, not working with credentials
24 replies
CDCloudflare Developers
Created by Silabear on 3/3/2023 in #pages-help
View live pages output
We're hosting a Svelte site on Pages, and our site throws a 500 Internal Server Error on page load (which should connect to our api and see if the user is authenticated). The deployment and build runs fine but not loading the page. https://085e5a11.datapackhub.pages.dev/ Is there any way to see the live logs?
6 replies