I've been having an issue I can't get to the bottom of, so finally asking here.
Context:
- I have one Railway project, with several services: one frontend (NextJS, App Router, mainly SSR), one backend service (Django), a database (postgres)
- Frontend tries to connect to the backend via private URL, and falls back to public URL if the initial connection fails (like when in client side, or during build)
- Frontend calls various APIs, as you'd expect, APIs return JSON
- There is no auth between services
- The backend has
django.middleware.gzip.GZipMiddlewareandcorsheaders.middleware.CorsMiddleware - The frontend has Cloudflare DNS, which I use to manage the domain
- I'm using the new proxy
Issue:
- I made a change to remove pagination in one of my APIs, and removed the associated pagination logic on the frontend
- After deploy, I get the attached error from my frontend during build
Things I've tried:
- Calling this API on the cmd line/postman works fine, and I get
Content-Encoding=gzipin the response headers - Disabling GZipMiddleware in Django, get the same result
- Mocking the response - returning hardcoded JSON - get same issue
- When I make the hardcoded JSON smaller, it often works - this makes me think it's a Gzipping issue (which triggers when the response is >200 bytes)
- Trying the legacy proxy - same result
- Setting
Accept-Encoding=gzip, deflate, brandContent-Type=application/jsonon the request in Next - Adding
DEFAULT_RENDERER_CLASSES=rest_framework.renderers.JSONRendererin Django - Praying
c18400df-5dee-4fe7-bc56-a98db8d475bd