Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BobbyAxe61's avatar

Laravel React process.env.REACT_APP_URL is Undefined

The react project was originally developed separately using create react-app but have been successfully merged in to the laravel app most of the pages load fine except for images that makes use of the process.env.REACT_APP_URL a log of process.env results in an empty object {} showing that the method is working but it is not picking up the react env variables.

I have checked against the common causes of this issue which are

  1. .env file is located at the root of the laravel project along with package.json and composer.json etc
  2. The react variable key names are all prefixed with REACT_APP
  3. dotenv package is installed in package.json
  4. i aways run npm run dev when ever i make a change if am not running npm run watch
  5. currently on laravel v7.6 and react v16.13.1

What could i be missing?

0 likes
2 replies
BobbyAxe61's avatar

i was using mix to compile didn't know it would ignore REACT_APP prefix :( thank you so much adding MIX_ prefix fixed my issue. Thank you.

Please or to participate in this conversation.