server only module
Unanswered
Tomistoma posted this in #help-forum
TomistomaOP
if i want a module to only be used on the server side for an api route handlers within app
my build process is currently failing because code that should only be executed server side with environment variables only available in the server (not the build process) are needed to run this module
app/api/user/route.ts and not be used whatsoever for the static page generation by nextjs, how do i make sure the build process does not run that code?my build process is currently failing because code that should only be executed server side with environment variables only available in the server (not the build process) are needed to run this module
1 Reply
TomistomaOP
my module looks something like this
and i use it in my routehandler.
how do i prevent this from being run in the build process
import { API_KEY } from '@/constants/common';
import { AuthZ } from 'somepackagename';
export const AuthZClient = new AuthZ({ apiKey: API_KEY });and i use it in my routehandler.
how do i prevent this from being run in the build process