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

hansara's avatar

Switching from laravel mix to vite in an old laravel proyect with vue 2 and docker

Hello everyone, I have spent a few days trying to make my application work with vite. I have follow everything the documentation says but I just cant get it to work. The app is build with laravel 9 vue 2 and it is dockerized. I get a message in the console with: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at... and a blank page. I am loosing my mind and I have no clue what to do. please help!

my vite.config

import { defineConfig } from 'vite';
import fs from 'fs';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue2';

export default defineConfig({
  plugins: [
    laravel({
      input: [
        'resources/assets/dashboard/js/app.js',
        'resources/assets/dashboard/scss/vendors.css',
        'resources/assets/dashboard/scss/custom.css',
        'resources/assets/dashboard/scss/components.scss',
      ],
    }),
    vue({
      template: {
        transformAssetUrls: {
          base: null,
          includeAbsolute: false,
        },
      },
    }),
  ],
  server: {
    host: 'localhost',
    https: {
      key: fs.readFileSync('./Docker/certs/talentu.local.key'),
      cert: fs.readFileSync('./Docker/certs/talentu.local.crt'),
    },
    hmr: {
      host: 'localhost',
    },
  },
});

my docker-compose

version: "3"
services:
  talentu-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "8080:80"
      - "443:443"
      - "${VITE_PORT:-5173}:${VITE_PORT:-5173}"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./Docker/jwilder-nginx/client_max_body_size.conf:/etc/nginx/conf.d/client_max_body_size.conf
      - ./Docker/certs:/etc/nginx/certs
    container_name: talentu_proxy
  talentu-db:
    image: mysql:5.7
    volumes:
      - ./Docker/mysql/my.cnf:/etc/my.cnf
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_DATABASE: "laravel"
      MYSQL_USER: "laravel"
      MYSQL_PASSWORD: "laravel"
      MYSQL_ROOT_PASSWORD: "laravel"
    depends_on:
      - talentu-proxy
    ports:
      - 42333:3306
    container_name: db.candidatos.talentu.local
  redis:
    image: redis
    depends_on:
      - talentu-proxy
    ports:
      - 6379:6379
    container_name: redis.talentu.local
  talentu-candidatos:
    build: .
    volumes:
      - .:/var/www/html:delegated
      - ./Docker/php/xdebug.ini:/etc/php/8.0/cli/conf.d/20-xdebug.ini:delegated
      - ./Docker/php/php.ini:/etc/php/8.0/fpm/php.ini:delegated
    environment:
      - VIRTUAL_HOST=*.talentu.local
      - VIRTUAL_PORT=443
      - VIRTUAL_PROTO=https
    depends_on:
      - talentu-db
    command: ["bash", "/var/www/html/Docker/bootstrap.sh"]
    container_name: candidatos.talentu.local
networks:
  default:
    external:
      name: talentu-network

Please help, I have no idea what is it that im missing. Tahnk you

0 likes
8 replies
jlrdw's avatar

Have you considered making a fresh laravel 10 app and migrating your M-V-C over? I did this recently and it was actually faster than trying to upgrade, just suggestion.

Or use laravel shift.

1 like
hansara's avatar

@jlrdw I havent, I dont know how that is going to impact the project. I have also used laravel shift for vite but no luck. I arrived at the same problem :( I dont knwo what else to do

jlrdw's avatar

@hansara you could backup everything first and give it a try on development server. For me it is usually easier to start a new project. But that is just my thoughts on it.

Also remember you can still use mix in a new project, vite is optional as well.

hansara's avatar

@jlrdw so.. I start a new project and copy all the app files into it?

jlrdw's avatar

@hansara no not all, just code you did, Models, views, controllers, custom classes, etc.

hansara's avatar

@jlrdw the problem is that the project im working on it very mature by now. we've been working on it for the past 4 years. Doing that would be crazy

hansara's avatar

@jlrdw yes, I think we are going to do that. The reason was because laravel mix its very slow at compilation and it is taking a lot of resources in the server when we update and re-compilate. we thought vite was going to make it a bit better in those cases

Please or to participate in this conversation.