Prisma 1 + MongoDB Atlas deploy to Heroku returns error 404
Opened this issue · 1 comments
Describe the bug
Trying to deploy to Heroku with a MongoDB Atlas cluster returns a 404 error.
To Reproduce
Steps to reproduce the behavior:
- Create a MongoDB Atlas tier 0 free sandbox cluster
- Configure a Prisma server app to connect on the previously created DB - (prisma.yml, docker-compose.yml)
- Deploy the Prisma server app to Heroku
- See error
Expected behavior
Launching prisma deploy
with the described configuration should create correctly the schemas then works in production as well as for localhost
environment.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions (please complete the following information):
- Connector: MongoDB
- Prisma Server: 1.34.10
prisma
CLI: 1.34.10- OS: OS X 10.15.5
- other dependencies:
prisma-client
,prisma-binding
, etc. if applicable
Additional context
As I stated here on StackOverflow, I've deployed a Prisma 1 GraphQL server app on Heroku, connected to a MongoDB Atlas cluster.
Running prisma deploy
locally with the default endpoint http://localhost:4466
, the action being run successfully and all the schemas are being generated correctly.
But, if I change the endpoint with the Heroku remote host https://<myapp>.herokuapp.com
, prisma deploy
fails, returning this exception:
ERROR: GraphQL Error (Code: 404)
{
"error": "\n<html lang="en">\n\n<meta charset="utf-8">\n<title>Error</title>\n\n\nCannot POST /management\n\n\n",
"status": 404
}
I think that's could be related to an authentication problem, but I'm getting confused because I've defined both security token in prisma.yml
than the management API secret key in docker-compose.yml
.
Here's my current configs if it could be helpful:
prisma.yml
# The HTTP endpoint for your Prisma API
# Tried with https://<myapp>.herokuapp.com only too with the same result
endpoint: https://<myapp>.herokuapp.com/dinai/staging
secret: ${env:PRISMA_SERVICE_SECRET}
# Points to the file that contains your datamodel
datamodel: datamodel.prisma
databaseType: document
# Specifies language & location for the generated Prisma client
generate:
- generator: javascript-client
output: ../src/generated/prisma-client
# Ensures Prisma client is re-generated after a datamodel change.
hooks:
post-deploy:
- prisma generate
docker-compose.yml
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
managementApiSecret: ${PRISMA_MANAGEMENT_API_SECRET}
databases:
default:
connector: mongo
uri: mongodb+srv://${MONGO_DB_USER}:${MONGO_DB_PASSWORD}@${MONGO_DB_CLUSTER}/myapp?retryWrites=true&w=majority
database: myapp
Plus, a weird situation happens too. In both cases, if I try to navigate the resulting API with GraphQL Playground, clicking on the tab "Schema" returns an error. On the other side, the tab "Docs" is being populated correctly. Apparently, seems that the exception is blocking the script finishing to generate the rest of the schemas.
A little help by someone experienced with Prisma/Heroku would be awesome.
Thanks in advance.
As I reported here I've found a solution.
I started to check my configuration from scratch by following step by step the official Prisma Cloud deployment guide to Heroku. The issue has been solved by itself, probably due to a misconfiguration.