-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Cloudflare pages/workers #751
Comments
Please give me some time to resolve this issue as I have no knowledge of Cloudflare pages or Cloud Flare workers. It'd be a good chance to reconsider how polyfills should be handled because Node.js 18 also natively supports FormData.
This is unintended. I inadvertently included a module that depends on |
Essentially they're running server-side code in V8 as service workers. A service worker can listen and respond to HTTP requests as fetch events: https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent Service workers don't have access to I get the same error using Masto from a Chrome extension, it runs code in the background like a service worker. But Chrome is fine with |
I believe this has been fixed in 4.9.2 #753 though you still have to use |
Thanks, the XHR error is gone now. However, |
In masto/fetch, if there is any masto.js/src/http/http-native-impl.ts Lines 35 to 43 in 57c5ebc
Example: Please check again if you are using the API as shown in the example. If you offer me a minimal repository to reproduce your problem, it would also help resolve your issue. |
I'm passing the base-64 encoded string directly since I already have that. This works fine in the browser, Separately, The place where you'd use |
Ah, I didn't know this. So I should've removed Content-Type regardless it has a Blob or not. As a workaround, please consider converting the data URI to a Blob by then. I'll keep you informed. |
@assaf Probably this is because I'm bad at googling, but I could not find any resource that says MDN says it's a string as plain text or a
|
There are two things going on here. One is that
You don't have to explicitly set the content type, and setting it to Two, Mastodon specifically handles
(You'll need Authorization header for the above to work) |
Thank you for explaining. I thought it was about FromData, but now I understand it is Mastodon's undocumented behaviour. I don't know it if is intended, but as you described, setting Content-Type to multipart/form-data doesn't seem to make sense. I made a PR that removes Content-Type when the body is an instance of FormData regardless if it's containing a Blob #758. It will be released soon |
I migrated the Cloudflare project from DIY to The following work:
|
🎉 This issue has been resolved in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I have a project that's deployed to Cloudflare. The runtime environment behaves like a service worker, so it has
fetch
but notwindow
, hence getting this error:There's a PR to fix isomorphic-form-data, I doubt it's getting merged: form-data/isomorphic-form-data#6
There's also no XHR (some specific technical reasons for that), so importing
masto/fetch
also fails:I wonder if there's an easy fix here, maybe a bundle that doesn't use any polyfills?
The text was updated successfully, but these errors were encountered: