0

I would like to know how I can use APP_URL from my .env file in the layout. Currently, I have the following.

<!-- Styles -->
<link rel="stylesheet" href="{{ asset(mix('css/styles.css')) }}">
<!-- Javascript -->
<script src="{{mix('js/app.js')}}"></script>

webpack.mix.js

const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');

// Styles
mix.sass('resources/scss/styles.scss', 'public/css')
.options({
    postCss: [ tailwindcss('./tailwind.config.js') ],
});

// Javascript [Dashboard]
mix.js('resources/js/app.js', 'public/js/app.js')
.vue();

However, when I run npm run prod and push on my server, the layout would always load like the following.

GET https://localhost:8080/css/styles.css net::ERR_CONNECTION_REFUSED2023:19 
GET https://localhost:8080/js/app.js net::ERR_CONNECTION_REFUSED

I set in my .env:

APP_URL=myurl.com

But the website would like to load localhost:8080 again. I use laravel-mix 6.0.27

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Jérémie Chazelle
  • 1,721
  • 4
  • 32
  • 70

1 Answers1

0

After updating APP_URL (or any other environment variables) in the .env file, it's necessary to clear the config cache to use the new values within the application.

php artisan config:clear
Karl Hill
  • 12,937
  • 5
  • 58
  • 95