🐞 Bug: Registration Failing Due to CORS Policy Error
📌 Overview
User registration is currently failing because the backend API is
blocking requests from the frontend domain due to a CORS (Cross-Origin
Resource Sharing) misconfiguration.
When a user attempts to sign up, the browser blocks the request during
the preflight check.
🌐 Affected Endpoint
POST https://pharmacy-74zf.onrender.com/user/register
Frontend Origin: https://pharmacy-mu-lovat.vercel.app
🚨 Console Error
Access to fetch at 'https://pharmacy-74zf.onrender.com/user/register'
from origin 'https://pharmacy-mu-lovat.vercel.app' has been blocked by
CORS policy: Response to preflight request doesn't pass access control
check: No 'Access-Control-Allow-Origin' header is present on the
requested resource.
POST https://pharmacy-74zf.onrender.com/user/register net::ERR_FAILED
TypeError: Failed to fetch
❌ Current Behavior
- Registration request fails.
- Browser blocks the API call.
- User sees: "An error occurred. Please try again."
- Console shows CORS error and
net::ERR_FAILED.
✅ Expected Behavior
- Backend should allow requests from the deployed frontend.
- Preflight OPTIONS request should return status 200.
- Proper CORS headers should be included in API responses.
- Registration should complete successfully.
🧠 Root Cause
The backend is not sending required CORS headers:
- Access-Control-Allow-Origin
- Access-Control-Allow-Methods
- Access-Control-Allow-Headers
Because of this, the browser blocks cross-origin requests during the
preflight phase.
💡 Suggested Fix (Backend - Express Example)
1️⃣ Install CORS middleware
npm install cors
2️⃣ Configure CORS properly
const cors = require("cors");
app.use(cors({
origin: "https://pharmacy-mu-lovat.vercel.app",
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true
}));
app.options("*", cors());
⚠️ For development only:
🖥️ Impacted Areas
- User Registration (/user/register)
- Login endpoint (potentially)
- Any API route accessed from frontend
🧪 Acceptance Criteria
🏷️ Labels
bug, backend, cors, api, high priority
🐞 Bug: Registration Failing Due to CORS Policy Error
📌 Overview
User registration is currently failing because the backend API is
blocking requests from the frontend domain due to a CORS (Cross-Origin
Resource Sharing) misconfiguration.
When a user attempts to sign up, the browser blocks the request during
the preflight check.
🌐 Affected Endpoint
POST https://pharmacy-74zf.onrender.com/user/register
Frontend Origin: https://pharmacy-mu-lovat.vercel.app
🚨 Console Error
Access to fetch at 'https://pharmacy-74zf.onrender.com/user/register'
from origin 'https://pharmacy-mu-lovat.vercel.app' has been blocked by
CORS policy: Response to preflight request doesn't pass access control
check: No 'Access-Control-Allow-Origin' header is present on the
requested resource.
POST https://pharmacy-74zf.onrender.com/user/register net::ERR_FAILED
TypeError: Failed to fetch
❌ Current Behavior
net::ERR_FAILED.✅ Expected Behavior
🧠 Root Cause
The backend is not sending required CORS headers:
Because of this, the browser blocks cross-origin requests during the
preflight phase.
💡 Suggested Fix (Backend - Express Example)
1️⃣ Install CORS middleware
npm install cors
2️⃣ Configure CORS properly
🖥️ Impacted Areas
🧪 Acceptance Criteria
🏷️ Labels
bug, backend, cors, api, high priority