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

krystof18's avatar

Vite behind reverse proxy

Hello, I'm creating docker development environment with nginx reverse proxy handling connections. I managed to add domain laravel.test to aim at php artisan serve running container on port 8000, but I have trouble when It tries to load javascript from Vite.

Its trying to reach host and port defined in vite.config.js:

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import vue from "@vitejs/plugin-vue";

export default defineConfig({

    server: {
        port: 3000, //here 
        host: "0.0.0.0", // and here
    },
    plugins: [
        laravel({
            input: "resources/js/app.js",
            ssr: "resources/js/ssr.js",
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    ssr: {
        noExternal: ["vue", "@protonemedia/laravel-splade"]
    },
});

but I want the backend to aim at laravel.test/vite so I can aim it at the reverse proxy and handle the request there, but I can't find a way to do it.

I tried to change the host to laravel.test/vite - it fails with Error: getaddrinfo ENOTFOUND laravel.test/vite

I also tried to add base domain but that does nothing.

Is there any way to configure it ideally outside the vite.config.js so It can run on any port withing the container and I can handle anything with the reverse proxy?

0 likes
0 replies

Please or to participate in this conversation.