Closed jstet closed 12 months ago
node-fetch
, as suggested in the openai issue. This was unfortunately not successful and cloudflare now has issues with internal behaviour of node-fetch
instead of axios
.undici
can be tried next. Addionally t might be possible to use node >= 18 which has native fetch support, but since that is internally implemented by undici
it is probably no different than trying undici
with older node versions.
Another suggestion seems to be the use of node-fetch
2 instead of 3 and in concrete terms ^2.6.1
.
undici
failed as well, and further research into the topic leads me to believe that the issue is not the dependency inside svelte.config.js
but the one inside $lib/js/directus_fetch.js
. Cloudflare does not support node-only modules at runtime, which only affects the latter case. This is also supported by the fact that the static build (which has been using node-only modules all along at build time) works.
If the above understanding is correct, it mean that we can essentially only use the browser fetch API inside the svelte code if we want it to work with cloudflare. The open question in this regard, is whether this will work in *.server.js
files or only in files that are guaranteed to run client side.
This can actually be tested more easily with a local npm run build
that uses the cloudflare adapter.
local npm run build
was able to reproduce the issue and migration to the (browser) fetch API inside svelte src removed the issue, first locally and then via #266 on the actual deployment.
See on Cloudflare:
500: adapter is not a function
might be related to this?: https://github.com/openai/openai-node/issues/30