Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use DATABASE_URL from env directly #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ You can get the connection details by clicking the `Connect` button.

Get `User` and `Host` field from the dialog.

> Note: For importing initial data from local, you can set an Allow All traffic filter here by entering an IP address of `0.0.0.0/0`.

![image](https://user-images.githubusercontent.com/56986964/183590950-93fb5778-128b-40e1-ab85-33994bd6f4de.png)

Your `DATABASE_URL` should look like `mysql://<User>:<Password>@<Host>:4000/bookshop`
Your `DATABASE_URL` should look like `mysql://<User>:<Password>@<Host>:4000/bookshop?sslaccept=strict`

#### 2. Deploy on Vercel

Expand Down
7 changes: 3 additions & 4 deletions lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ declare global {
let prisma: PrismaClient

const { TIDB_USER, TIDB_PASSWORD, TIDB_HOST, TIDB_PORT, TIDB_DB_NAME = 'bookshop', DATABASE_URL } = process.env;
// Notice: When using TiDb Cloud Serverless Tier, you **MUST** set the following flags to enable tls connection.
const SSL_FLAGS = 'pool_timeout=60&sslaccept=accept_invalid_certs';
// Notice: When using TiDB Cloud Serverless Tier, you **MUST** set the following flags to enable tls connection.
const databaseURL = DATABASE_URL
? `${DATABASE_URL}?${SSL_FLAGS}`
: `mysql://${TIDB_USER}:${TIDB_PASSWORD}@${TIDB_HOST}:${TIDB_PORT}/${TIDB_DB_NAME}?${SSL_FLAGS}`;
? `${DATABASE_URL}`
: `mysql://${TIDB_USER}:${TIDB_PASSWORD}@${TIDB_HOST}:${TIDB_PORT}/${TIDB_DB_NAME}?pool_timeout=60&sslaccept=accept_invalid_certs`;

if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient({
Expand Down