P
Prisma3mo ago
Virgile

How to authenticate Prisma Optimize in a VPS ?

Hi everyone. I enabled Prisma Optimize on a project to try it out. On local, I can authenticate using the browser, all works well. On a VPS though, I pushed to prod and my website crashed. How can we authenticate to Prisma on a VPS ? What command could I run before hand to avoid this issue ? I have a production and a preproduction environment, do I need to authenticate for both, or only for one ? Do we need to run this command inside the project, alongside the schema.prisma ? Thanks !
6 Replies
Virgile
Virgile3mo ago
So here's what I did : Installed xdg-utils because you apparently need it to run the command
sudo apt-get update
sudo apt-get install xdg-utils
sudo apt-get update
sudo apt-get install xdg-utils
Then it successfully kept the CLI running and sent me a link, redirecting to 127.0.0.1. Except I'd like to connect to my VPS server. So I replaced 127.0.0.1 with server IP, but I could not access it. I'm using EC2 on AWS with security groups allowing connections from all ports. But I'm using Caddy Server, which apparently does not allow any connection not configured in its config file. Since the port changes everytime I ran the command, I cannot predict in advance the port to open.
Nurul
Nurul3mo ago
Hey @Virgile 👋 Thank you for trying out Prisma Optimize. At the moment, Prisma Optimize is supposed to be used in local development only. It isn't designed to use in production environment yet. Though, this is in our plans and we will support using it in production environments as well.
Virgile
Virgile3mo ago
thank you for replying 🙂
Nurul
Nurul3mo ago
No worries! 😄
Virgile
Virgile2mo ago
Alright it does not seem to work in my project. Using NestJS with a service
import { Inject, Injectable } from "@nestjs/common";
import type { ConfigType } from "@nestjs/config";
import { PrismaClient } from "@prisma/client";

@Injectable()
export class PrismaService extends PrismaClient {
constructor() {
super();
this.$extends(withOptimize());
}
}
import { Inject, Injectable } from "@nestjs/common";
import type { ConfigType } from "@nestjs/config";
import { PrismaClient } from "@prisma/client";

@Injectable()
export class PrismaService extends PrismaClient {
constructor() {
super();
this.$extends(withOptimize());
}
}
I've tried using it directly before calling a resource, like this.prisma.$extends(withOptimize()).users.findMany(). It's getting me the users, showing console.logs to preview the data. But there is no data in the dashboard
Nurul
Nurul2mo ago
Is your repository open source? Any way I can run this?