Mastra in Google Cloud Run
I am having a difficult time using Mastra in GCP Cloud Run. I have enabled CORS in the most permissive way possible. I connected Mastra Cloud with my Mastra server in Cloud Run, and I can see the agents and workflows and everything, but when I tried to chat with an agent, I see some network error message showing up. Upon refresh, I see my message 4 times, and Mastra server replied 4 times. Inspecting the networks, I see 4 POST requests which resulted in CORS error, but I think it is not CORS related.
The endpoint I am invoking is
https://mastra-ai-service-***.europe-*****.run.app/api/agents/weatherAgent/stream, and I see in Bruno/Postman 502 Bad Gateway: upstream connect error or disconnect/reset before headers. reset reason: protocol error. Thus, this is not directly a CORS problem. Then, I inspected the GCP Cloud Run log, and I only see
So there is nothing useful in the log, even though I have set the PinoLogger to DEBUG level.
Has anyone successfully run Mastra in Google Cloud Run? Did you connect Mastra cloud to it? Please share.4 Replies
๐ Created GitHub issue: https://github.com/mastra-ai/mastra/issues/9572
GitHub
[DISCORD:1433785136364781720] Mastra in Google Cloud Run ยท Issue #...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433785136364781720 I am having a difficult time using Mastra in GCP Cloud Run. I have enabled CORS in the...
Hey @Karl ! Are you able to interact with your Mastra API endpoint outside of Studio?
Hi Romain, I cannot interact with Mastra Streaming API even outside of Studio. I tried with Postman and it does not work.
The fix for me was to not use Google Cloud Run, and instead I switched to Digital Ocean App Platform.
My team lead is also Romain, so for a moment I thought my team lead reached out to me even here ๐
Hi @Karl do you have a cors config in the Mastra instance?
We have people using cloud run like @kosukeoya