kanertuncel
CDCloudflare Developers
•Created by kanertuncel on 9/19/2023 in #workers-help
Worker fetch returns unexpected 404
I'm trying to execute a simple fetch to my domain (domain.com) but it responds with 404. I'm desperate and really need help.
1. Yes, the page, domain and url is accessible.
2. Tried and tested almost everything comes to mind first (ssl, typo, cors, http method etc.)
3. Worker can actually do fetch, i tried changing url to webhook.site
4. domain.com can receive fetch, you can also try.
5. Deleted and recreated the worker
6. Works even redirecting the fetch to my localhost using ngrok
Here is my worker:
async email(event: ForwardableEmailMessage) {
const rawEmail = await streamToArrayBuffer(event.raw, event.rawSize);
const parser = new PostalMime();
const parsedEmail = await parser.parse(rawEmail);
//works if i change the url anything but payload.email
const res = await fetch('https://domain.com/api/inbound/', {
body: JSON.stringify(parsedEmail),
headers: { 'Content-Type': 'application/json' },
method: 'POST',
});
console.log(await res.status); //404
}
i'm out of ideas to try so any ideas would really help, thanks in advance.2 replies