Hi Render Community,
I’m encountering a persistent and puzzling issue with my deployed Vite/React frontend static site (ashlight-frontend at https://ashlight-frontend.onrender.com) where its GraphQL API calls are being misdirected. Instead of going to my Render-hosted backend service (ashlight-backend at https://ashlight-backend.onrender.com), the requests are somehow being sent to the frontend’s own domain (https://ashlight-frontend.onrender.com/graphql).
This happens primarily after user login when the application attempts to fetch data. The result is a 200 OK response (likely index.html or an empty response from the static server) which then causes an ApolloError: ServerParseError - Unexpected end of JSON input in the client because it’s not valid JSON.
What I’ve Confirmed/Tried:
- Environment Variable (
VITE_API_BASE_URL):
- Correctly set in
ashlight-frontend’s environment settings on Render tohttps://ashlight-backend.onrender.com. - Console logs from the deployed
apolloClient.jsconfirmimport.meta.env.VITE_API_BASE_URLis read correctly and the Apollo ClienthttpLinkis initialized with the correct target URI (https://ashlight-backend.onrender.com/graphql). - Despite this, Network tab shows requests going to
https://ashlight-frontend.onrender.com/graphql.
- Hardcoded Absolute URL Test:
- I modified
apolloClient.jsto hardcode the absolute backend URL ('https://ashlight-backend.onrender.com/graphql') directly into thecreateHttpLinkconfiguration, bypassing environment variables entirely. - After a “Clear build cache and deploy,” the browser’s Network tab still showed the GraphQL request being sent to
https://ashlight-frontend.onrender.com/graphql.
- Caching Attempts:
- Consistently tested with hard refreshes and in Incognito/Private browser windows.
- Attempted to set aggressive
Cache-Controlheaders viastatic.json(though Render Support clarified this isn’t the method for static sites and deployments should invalidate the CDN cache anyway. The correct method is via the dashboard “Headers” page, which I haven’t tried yet forCache-Controlas the hardcoding test failure makes CDN caching of old JS seem less likely to be the sole root cause).
- Render Settings Checked:
- Redirects & Rewrites: The “Redirects & Rewrites” section for
ashlight-frontendin the Render dashboard is empty. - Monorepo Settings: Root Directories for both frontend (
client/) and backend (server/) services are believed to be set correctly. Build commands are standard (npm install && npm run buildfor client,npm installfor server).
- Backend Functionality:
- Direct
curltests tohttps://ashlight-backend.onrender.com/graphql(with necessary headers) and other test endpoints on the backend succeed and return expected JSON/responses. - Backend logs show no incoming requests from the deployed frontend when the misdirection occurs.
Project Details:
- Frontend: Vite, React, Apollo Client, deployed as a Static Site on Render.
- Backend: Node.js, Express, Apollo Server, Mongoose, deployed as a Web Service on Render.
- Repository (Public):
https://github.com/wileland/AE - Frontend Live URL:
https://ashlight-frontend.onrender.com - Backend Live URL:
https://ashlight-backend.onrender.com
My Question for the Community:
Has anyone experienced a similar issue where a static site on Render misdirects API calls to its own domain, even when an absolute URL to another Render service is explicitly configured or hardcoded in the client-side JavaScript? Any insights into what might be causing this at the Render platform level, build process, or networking layer would be greatly appreciated.
I have an ongoing support ticket with Render, but I’m hoping for any community wisdom as well.
Thanks for any help or suggestions!
Will