n Use laravel .env variable in Vue.js | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Use laravel .env variable in Vue.js

 

Example .env file:

MIX_API_URL="http://example.com/api/v1"

 

To use laravel .env variable in Vue.js we simply call

process.env.MIX_API_URL

In the real world, it will look like so

data() {
   return() { 
     api_key: process.env.MIX_API_URL
  }
}

We can now use the laravel .env file to host and use any variables we don't want to store in javascript.

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook