pull/9078/head
zomars 2022-12-02 15:22:56 -07:00
parent d35f27014e
commit e15f6abc9b
2 changed files with 4 additions and 6 deletions

View File

@ -2,10 +2,11 @@ import { hash } from "bcryptjs";
import cache from "memory-cache";
import { NextMiddleware } from "next-api-middleware";
import { PRISMA_CLIENT_CACHING_TIME } from "@calcom/api/lib/constants";
import { CONSOLE_URL } from "@calcom/lib/constants";
import { prisma, customPrisma } from "@calcom/prisma";
import { PRISMA_CLIENT_CACHING_TIME } from "../../lib/constants";
// This replaces the prisma client for the cusotm one if the key is valid
export const customPrismaClient: NextMiddleware = async (req, res, next) => {
const {
@ -18,9 +19,7 @@ export const customPrismaClient: NextMiddleware = async (req, res, next) => {
return;
}
// If we have a key, we check if the deployment matching the key, has a databaseUrl value set.
const databaseUrl = await fetch(
`${process.env.NEXT_PUBLIC_CONSOLE_URL || CONSOLE_URL}/api/deployments/database?key=${key}`
)
const databaseUrl = await fetch(`${CONSOLE_URL}/api/deployments/database?key=${key}`)
.then((res) => res.json())
.then((res) => res.databaseUrl);

View File

@ -1,3 +1,4 @@
import { Prisma } from "@prisma/client";
import type { NextApiRequest } from "next";
import { defaultResponder } from "@calcom/lib/server";
@ -5,8 +6,6 @@ import { defaultResponder } from "@calcom/lib/server";
import { withMiddleware } from "~/lib/helpers/withMiddleware";
import { schemaUsersReadPublic } from "~/lib/validations/user";
import { Prisma } from ".prisma/client";
/**
* @swagger
* /users: