You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was interested in deploying my application in a serverless environment, more specifically Cloudflare Workers. At the moment, Axios is the HTTP library used for interacting with the Medusa API via the client that's explored from this package.
Service Workers can only operate using fetch and don't support XMLHttpRequest. In addition, the stable method for deploying Cloudflare Workers is via service-worker. So, unfortunately, Axios cannot be used in in PWA service workers or Cloudflare Workers.
The primary maintainer of Axios just said in October that they're going to be moving to a V1 which would support a `fetch based adapter in order to use it in different deployment contexts such as Cloudflare Workers. However, if you scroll down to his comment here,
Version 1 will very easily be a year long project, we can still add features, make fixes etc as long as we don't break anything in terms of BC.
So converting Axios is a long way out in order to use Medusa in its current state in environments that only support the fetch API. This is kind of a super blocker for using one of the more popular methods of deploying serverless applications.
Update the Medusa App to use plain old fetch instead of using Axios. This would probably require some breaking changes as that the types and a few of the interfaces would have to change surrounding errors, replies, and responses.
Update the client options so that fetch can be used instead of Axios without re-writing the entire module
Thoughts?
The text was updated successfully, but these errors were encountered:
drewdecarme
changed the title
Can't use Medusa in Cloudflare Workers due to Axios limitations
Can't use Medusa in service workers or Cloudflare Workers due to Axios limitations
Dec 1, 2021
Issue
I was interested in deploying my application in a serverless environment, more specifically Cloudflare Workers. At the moment, Axios is the HTTP library used for interacting with the Medusa API via the client that's explored from this package.
Service Workers can only operate using
fetch
and don't supportXMLHttpRequest
. In addition, the stable method for deploying Cloudflare Workers is viaservice-worker
. So, unfortunately, Axios cannot be used in in PWA service workers or Cloudflare Workers.Here's a the main issue: axios/axios#1219
The primary maintainer of Axios just said in October that they're going to be moving to a V1 which would support a `fetch based adapter in order to use it in different deployment contexts such as Cloudflare Workers. However, if you scroll down to his comment here,
So converting Axios is a long way out in order to use Medusa in its current state in environments that only support the
fetch
API. This is kind of a super blocker for using one of the more popular methods of deploying serverless applications.Potential Solutions
fetch
adapter for Axios contentful/contentful.js#396Thoughts?
The text was updated successfully, but these errors were encountered: