metamcp: Cannot access web application behind CloudFlare Tunnels due to CORS error
- I used Docker Compose to deploy MetaMCP + Postgres on my headless Linux server.
- I configured CloudFlare Tunnels to send network traffic to the MetaMCP container (eg.
https://mcp.mydomain.dev-->http://10.0.0.49:12008). - When I try to go to the webpage https://mcp.mydomain.dev, I get a CORS error, even though I correctly set the
APP_URL=https://mcp.mydomain.dev - Both the
Current DomainandAuthorized Domainvalues are exactly the same
Why am I getting a CORS error if the current and authorized domain are exactly matching correctly?
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (8 by maintainers)
You’re welcome! I cleared cookies for the site and that appears to have fixed the React minification error. I’m currently running on 2.2.5 just fine. I will keep an eye out for new releases. Keep up the great work!
I’m on Discord if you want to chat: same username.
Thanks for helping. That looks like a middleware bug that skips /api. But I believe I have fixed that, and in latest https://github.com/metatool-ai/metamcp/tree/no-cors branch, I don’t see that error.
docker compose build metamcpdocker compose up --detachNow I’m getting a different console error, but the web UI still seems to load.
Pushed a potential fix to the same branch.
Thanks for helping, I found that if I remove APP_URL var, then some times when window is undefined the code sometimes won’t work, I will try if I can resolve it or not.
In this branch I completely removed CORS and it should support any domain or ip:port. @pcgeek86 if you want to use this one you can manually build the docker image from source in https://github.com/metatool-ai/metamcp/tree/2.3-no-cors (check docker-compose.dev.yml)
I found that when I set the APP_URL in .env back to localhost:12008 and not use my mcp.xxxx.local domain name then edit the auth.ts file in \metamcp\apps\backend\src and add your app domain name to the trustedOrigins: like below
"http://localhost", // Added this line to fix the "Invalid origin" error "http://localhost:3000", "http://localhost:12008", "http://127.0.0.1", // Also added this for good measure "http://127.0.0.1:12008", "http://127.0.0.1:3000", "http://0.0.0.0", "http://0.0.0.0:3000", "http://0.0.0.0:12008", "http://mcp.xxxx.local:8081, "http://mcp.xxxx.local:12008, "http://mcp.xxxx.local,I wasn’t sure if I needed to put all 3 mcp.xxxx.local names in but it is now working for me so worth a try.
I can confirm that 2.2.1 is working just fine. I am logged into the web UI now.
The use case make sense, let me think about how to implement that. Initially I thought straight one URL access and CORS is most secure, but will figure that out.
sorry for the inconvenience, weird, will completely remove it from middleware. to unblock I think 2.2.1 should work. I am pushing a fix build
Reverted my CORS error page in 2.2.3 (latest) sorry for the inconvenience