Process is not defined when trying to access strapi locally

When I try to load strapi locally, I’m greeted by the issue pictured. It’s seems to be failing immediately while trying to get the cms title.

Let me know if anyone has experienced this before.

This topic has been created from a Discord post (1227286864763817995) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

It’s seems to be failing immediately while trying to get the cms title.

Let me know if anyone has experienced this before.

This is the place the error is pointing too

you shouldn’t be loading environment variables in the frontend

you should create a custom route/controller and have the frontend request the data from the backend.

Ah nvm that’s our code I see, can you give your package.json?

I’m guessing the drag/drop content-types plugin is breaking something, if you remove that does it run properly?

Im out of office now, but I’ll have a look first thing in the morning

and I’ll let you know

Hey, I disabled that plugin and I have the same issue

We can actually close this issue, I just found the problem, was a previous commit I wasn’t aware of where we were overriding some of the translations

Btw, why should we not load env variables?

This seems to work fine in older versions but it no longer does in 4.20.1

It’s a best practice thing, those env vars need to exist during the build phase and plugins really should not be loading vars during the build phase unless they absolutely have too. It should request those vars from the backend, both for security (since if they exist in the build phase they will be hard coded in the build itself and made avaliable to unauthenticated users).

It’s safer/more secure to request them from the backend with auth.

Strapi uses React, aka CSR, so they HAVE to be built into the react build if they exist during build time.

Okay, so lets say you have a case where you need different values for each environment you’re on. What would be the best way to use different values outside of env vars?

(This is also the case I have lol)

you can use our built in environment system, the key thing is you don’t give them to the frontend directly, the frontend asks the backend for them via a route (those env vars are just given to the backend and read at runtime, not build time)

I couldn’t find any examples of using the env system in the extensions directory, which is where I’m doing this

Is it possible to use that there?