Skip to content

fix: Support both MEDUSA_BACKEND_URL and NEXT_PUBLIC_MEDUSA_BACKEND_URL in middleware #485

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

Conversation

Vallabh-Mahanta
Copy link

Description

This PR fixes issue #484 where the middleware only accepts MEDUSA_BACKEND_URL environment variable but not NEXT_PUBLIC_MEDUSA_BACKEND_URL, which causes confusion and errors when setting up the storefront.

Changes

  • Updated the middleware to check for both MEDUSA_BACKEND_URL and NEXT_PUBLIC_MEDUSA_BACKEND_URL environment variables
  • Updated error messages to be more clear about the environment variables needed
  • Updated the .env.template file to include both variables with explanations
  • Updated README.md to document both environment variables

Testing

Tested by running the application with only NEXT_PUBLIC_MEDUSA_BACKEND_URL defined, which now works correctly.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update (fixing inaccurate or missing information)

Affected Components

  • Middleware
  • Documentation

Related Issues

Fixes #484

Copy link

vercel bot commented Apr 24, 2025

@renoschubert is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

@VariableVic VariableVic closed this May 6, 2025
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

Successfully merging this pull request may close these issues.

[Bug]: Middleware fails when using NEXT_PUBLIC_MEDUSA_BACKEND_URL environment variable
2 participants