0
votes

get data from .env on Laravel to LARAVEL NOVA HOME in vue component

I need get data from .env on LARAVEL to use on Laravel Nova Card

On .env i have: APP_URL=https://example.com

I need to get this value from Laravel .env to generate nav links dynamically in the first page after LARAVEL NOVA login page on (MAIN PAGE) - LARAVEL NOVA DASHBOARD

the Main Page have 6 icons (This are the nav links)

I need to return six links like:

https://example.com/one-page

https://example.com/two-page

https://example.com/three-page

https://example.com/four-page

https://example.com/five-page

https://example.com/six-page

I need from .env because if change URL of the project, I need only change in .env to not broken main navigation card on LARAVEL NOVA MAIN PAGE

1

1 Answers

-1
votes

Vue works on frontend side aka application layer. I don't think dotenv works for you there. I suggest you to pass the value through .blade.php in scripts.

<script>
   const window.MIX_APP_URL = {{ env('MIX_APP_URL') }};
</script>

and use the MIX_APP_URL variable for the value in vue.

data() {
  return {
    appUrl: window.MIX_APP_URL,
  }
}