Cannot access SSL certificates when deploying to production on Vercel
See original GitHub issueBug description
I am building a website using Nextjs + Apollo server micro + Apollo client + Prisma, with a GCP Postgresql database.
When working on my local machine, migrations, queries and mutations work on my local test database and my production database (for example running yarn prisma migrate up --experimental
).
However after deployment to production, when I trigger a first query, i’m getting this error Uncaught (in promise) Error: Error opening a TLS connection: cert file not found (No such file or directory (os error 2))
.
For local development I use dotenv cli
to manage environments for my DATABASE_URL.
As SSL security is implemented the url looks like this DATABASE_URL="postgresql://USER:PASSWORD@IP:PORT/DATABASE_NAME?schema=public&sslmode=required&sslcert=../server-ca.pem&sslidentity=../client-identity.p12&sslpassword=PASSWORD&sslaccept=strict"
as described in this issue
For the production build I use the Vercel Secrets feature to store the DATABASE_URL.
I have tried the solution presented here, by using the relative path to the root folder, as well as absolute path with no success.
I have tried logging the database URL on build, and it is showing me the ‘correct’ URL, (the one I implemented).
My file structure is like this . | pages |— api |—— graphql.js | prisma |— migrations |— schema.prisma | server-cert.pem | client-identity.p12
Prisma information
I’m using @prisma/client 2.11.0
Environment & setup
- OS: Mac OS
- Database: PostgreSQL (Google Cloud)
- Node.js version: 14.4.0
- Prisma version:
@prisma/cli : 2.11.0
@prisma/client : 2.11.0
Current platform : darwin
Query Engine : query-engine 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/query-engine-darwin)
Migration Engine : migration-engine-cli 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Studio : 0.311.0
How the Prisma client is called in my graphql.js
import { makeSchema, objectType, stringArg, intArg, asNexusMethod } from '@nexus/schema'
import { GraphQLDate } from 'graphql-iso-date'
import { ApolloServer } from "apollo-server-micro";
import { PrismaClient } from '@prisma/client';
import path from 'path';
export const GQLDate = asNexusMethod(GraphQLDate, 'date')
console.log(process.env.DATABASE_URL)
const prisma = new PrismaClient()
const Depute = objectType({
name: 'Depute',
definition(t) {
t.string('id')
t.string('first_name')
t.string('last_name')
},
})
const Query = objectType({
name: 'Query',
definition(t) {
t.field('depute', {
type: 'Depute',
args: {
id: stringArg({ nullable: false }),
},
resolve: (_parent, args, _ctx) => {
return prisma.depute.findOne({
where: { id: args.id },
})
},
})
},
})
export const schema = makeSchema({
types: [Query, Depute, GQLDate],
outputs: {
typegen: path.join(process.cwd(), 'pages', 'api', 'nexus-typegen.ts'),
schema: path.join(process.cwd(), 'pages', 'api', 'schema.graphql')
},
})
export const config = {
api: {
bodyParser: false,
},
};
export default new ApolloServer({
schema,
debug: true
}).createHandler({
path: '/api/graphql',
});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
Would it be possible to modify this error to indicate where the file was expected to be?
Yes, if you open a issue with a current reproduction that triggers the error and describe what it could or should output, we are happy to take a look. Shouldn’T be too hard.