Skip to content
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

Can't use Medusa in service workers or Cloudflare Workers due to Axios limitations #857

Closed
drewdecarme opened this issue Dec 1, 2021 · 1 comment

Comments

@drewdecarme
Copy link

drewdecarme commented 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 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.

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,

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.

Potential Solutions

  1. Update the instance of Axios you're using to the fork of Axios that Contentful uses, which has a patch already added to it to use fetch. Read more on the fork here: Fix: Upstream fetch adapter for Axios contentful/contentful.js#396
  2. 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.
  3. Update the client options so that fetch can be used instead of Axios without re-writing the entire module

Thoughts?

@drewdecarme 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
@srindom
Copy link
Collaborator

srindom commented Dec 12, 2022

@drewdecarme - We are moving feature requests to GitHub Discussions to keep better track of the most requested features (using the upvote mechanism) and streamline GitHub Issues around bugs. Could I ask you to re-open your request here: https://github.com/medusajs/medusa/discussions/categories/feature-requests

Thanks!

@srindom srindom closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants