Bug Description
Frontend requests to http://localhost:5000/api/auth/me are failing when the app is served from https://dailyforge-frontend-lhjq.onrender.com.
Browser console shows:
Access to XMLHttpRequest at 'http://localhost:5000/api/auth/me' from origin 'https://dailyforge-frontend-lhjq.onrender.com' has been blocked by CORS policy: Permission was denied for this request to access the loopback address space.
GET http://localhost:5000/api/auth/me net::ERR_FAILED
Network error. Please check your connection.
This appears to be caused by Private Network Access (PNA) preflight restrictions when a public origin calls a localhost backend.
Steps to Reproduce
- Open the deployed frontend at
https://dailyforge-frontend-lhjq.onrender.com.
- Trigger auth/session fetch that calls
GET /api/auth/me.
- Inspect browser console/network tab.
- Observe failed request to
http://localhost:5000/api/auth/me and CORS/PNA denial.
Expected Behavior
Auth endpoint request should succeed (or fail with a normal API auth response), without browser-level CORS/PNA blocking.
Actual Behavior
Request is blocked by browser before successful API communication due to CORS/PNA policy.
Probable Root Cause
- Frontend is configured to call a localhost API from a public domain.
- Backend likely does not return required preflight headers for private network requests.
Suggested Fix
- Avoid using
localhost as API base URL for publicly hosted frontend builds.
- Point frontend to a publicly hosted backend URL (staging/production API).
- For development/testing where this flow is necessary, update backend CORS handling to support preflight correctly, including
Access-Control-Allow-Private-Network: true when access-control-request-private-network is present.
Example (Express):
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors({
origin: 'https://dailyforge-frontend-lhjq.onrender.com',
credentials: true,
}));
app.use((req, res, next) => {
if (req.headers['access-control-request-private-network']) {
res.setHeader('Access-Control-Allow-Private-Network', 'true');
}
next();
});
Acceptance Criteria
Additional Context
Error trace references bundled frontend file:
If helpful, we can also add an environment-guard check to fail fast when localhost API URLs are used in production frontend builds.
Bug Description
Frontend requests to
http://localhost:5000/api/auth/meare failing when the app is served fromhttps://dailyforge-frontend-lhjq.onrender.com.Browser console shows:
Access to XMLHttpRequest at 'http://localhost:5000/api/auth/me' from origin 'https://dailyforge-frontend-lhjq.onrender.com' has been blocked by CORS policy: Permission was denied for this request to access the loopback address space.GET http://localhost:5000/api/auth/me net::ERR_FAILEDNetwork error. Please check your connection.This appears to be caused by Private Network Access (PNA) preflight restrictions when a public origin calls a localhost backend.
Steps to Reproduce
https://dailyforge-frontend-lhjq.onrender.com.GET /api/auth/me.http://localhost:5000/api/auth/meand CORS/PNA denial.Expected Behavior
Auth endpoint request should succeed (or fail with a normal API auth response), without browser-level CORS/PNA blocking.
Actual Behavior
Request is blocked by browser before successful API communication due to CORS/PNA policy.
Probable Root Cause
Suggested Fix
localhostas API base URL for publicly hosted frontend builds.Access-Control-Allow-Private-Network: truewhenaccess-control-request-private-networkis present.Example (Express):
Acceptance Criteria
localhostin non-local environments.GET /api/auth/mesucceeds from deployed frontend with correct CORS behavior.loopback address spaceCORS/PNA errors appear in browser console for auth flow.Additional Context
Error trace references bundled frontend file:
index-2aqmWhIF.jsIf helpful, we can also add an environment-guard check to fail fast when
localhostAPI URLs are used in production frontend builds.