Pages & R2
It is third day and am still struggling to implement a simple mechanism for uploading a file using pages and functions. Good news is that I have progressed a little since two days ago. Everything seems to work locally when I test file uploading from postman but not working on internet when I deploy the app. What could be a probable reason for this bug? Attached are screens of code snippets both for handling the submit event on the client and processing the request in the function. Env variable is down in the dashboard as 'PIC',
upload.ts
file is located in the api
folder which is inside functions
folder which is located in the root folder of the app. Attempt to upload the file results in 500 status error with the message 'internal server error'12 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
wrangler pages dev . --persist --r2=PIC -- npm run dev
how do I use Realtime Logs? when I try to google cloudflare realtime logs
so many things relted to logs come up: instant logs
, r2 logs
, web analytics logs
, cloudflare logs docs
etcUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
Thank you. Just tried it. The error I see in the logs is
Network connection lost
Could it be that this error is related to how I implemented client and not related to cloudflare at all?
I see this error re Network connection lost
every time I run the requestUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ok, thank you. Let me try to set up cors headers, maybe that is causing the issue
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
cool. thank you
Sid, may I please ask few more minutes of your time? when I run the app locally, the client (built using astro and vanilla js) runs on port 3000 and on port 8788 because I ran
wrangler pages dev --r2=PIC -- npm run dev
. The one that runs on 3000 responds with the same error as the app deployed to the web, while the other that runs on 8788 works properly with no errors. Could it be that somehow when I deploy my app, the client served on maqal.pages.dev
(this is the domain that my app is available on when deployed) is the same client that is served on port 3000 while what I need is the one that is served on 8788?Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I have checked the guide, installed the adapter but still no success
yes, astro site is working without functions well without any errors
it seems that during deploy stage functions are not picked up (i.e. not registered) because when I click the submit button it does request the correct url but results in 404 as if no route exists
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yeah, that's what I thought as well. Started discussing this issue there. Thank you for your help here