Server-Side Code Isolation in Start #2671
-
First, I have a question regarding server-side code isolation: Is there a mechanism to ensure certain code runs exclusively on the server? For context:
Is there a recommended approach or best practice for handling this use case? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I am experimenting with Start and had the same concerns about leaking sensitive things like db/api credentials and connections. Couple of options I've found that are worth a test:
|
Beta Was this translation helpful? Give feedback.
I am experimenting with Start and had the same concerns about leaking sensitive things like db/api credentials and connections.
Couple of options I've found that are worth a test:
import 'server-only'
: I don't particularly like this method because I don't want credentials leaking because of me forgetting to put the import in.vite-env-only
: I've not tested this but by the looks of it I'm really hoping it works. I think this + aneslint
rule to ensurecreatesServerFn
calls only exist in a**/*.server.*
pattern is going to be my preferred path forward.