Thank you both so much for looking at this one with me. The weird thing is, I deleted my deployed instances in render.com and redeployed the last night and the problem is… gone. I have a theory as to what was happening and a theory as to why it is now fixed, but first let me respond to what you’ve said.
@rob in answer to your questions, I only saw this when deployed (never in development). I only ran into these problems when logged in (at least that I noticed). I don’t have a chance anymore to look at the faulty auth?method=getToken
calls anymore, but I do think that my request was getting processed by the frontend.
@Tobbe hmm that is strange. I wonder if that response contains their index.html
.
Now as for my theories:
Why did I see this problem before?
When I initially deployed to render.com, the deployment for my api functions failed, and that confused me. I started messing around with DBAUTH_COOKIE_DOMAIN
and cors and a few other things, trying to get render.com to serve my services correctly. Among the things I tried was updating my render.yaml
file to contain this rewrite, as instructed on their site (Deploy RedwoodJS | Render · Cloud Hosting for Developers):
routes:
- type: rewrite
source: /.redwood/functions/*
destination: https://wavepoolmvp-api.onrender.com/*
The full redirect/rewrite logic for my site looks like this:
routes:
- type: rewrite
source: /.redwood/functions/*
destination: https://wavepoolmvp-api.onrender.com/*
- type: rewrite
source: /*
destination: /index.html
After noticing that my index.html
file was being served as an authorization bearer, that second rewrite to /index.html
caught my eye. My theory as to what was happening is this: sometimes (not sure why or what triggered it) the first rewrite to my api server failed and the second one was activated.
This seemed to be random and I didn’t notice any pattern between requests that were successfully routed to my api and requests that were rewritten to /index.html
. It seemed to affect about half of auth?method=getToken
requests and none of my other requests.
What fixed it?
First off, I want to say that I don’t know it’s fixed. I guess I won’t know until I and many others have used my site for a while without issue. But I have tested it on different devices in different browsers and haven’t seen this glitch once.
All that I did was completely delete my previous instances for my whole project on render.com (web, api, and db) and redeploy them. I had to upgrade my api instance to starter plus again for the extra RAM (annoying), but beyond that it was just a simple deploy. And everything worked! No DBAUTH_COOKIE_DOMAIN
or cors configuration or anything.
Conclusion
Hopefully this is all in the past and others who have issues with this when deploying to render.com can learn from my mistakes. Thank you so much for looking at this with me. If I run in to more bugs with this I’ll update the thread.
Here’s my website if you’re interested: https://wavepool.events