Logo

dev-resources.site

for different kinds of informations.

[SOLVED]Yet another docker + vite, The connection was reset

Published at
10/23/2023
Categories
vite
laravel
docker
cors
Author
tomelsj
Categories
4 categories in total
vite
open
laravel
open
docker
open
cors
open
Author
7 person written this
tomelsj
open
[SOLVED]Yet another docker + vite, The connection was reset

Alright, I am at my wit's end here. I am trying to run vite inside a docker container, that's it. Together with the Laravel plugin 'laravel-vite-plugin'. In a php:8.1-apache container. But it won't load. The console screams
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5173/@vite/client. (Reason: CORS request did not succeed). Status code: (null).
When I try to visit http://localhost:5173/@vite/client, the browser tells me, "The connection was reset.". Not sure how else debug this through.

I run a standard php:8.1-apache Dockerfile with docker-compose build and docker-compose up. All I added are some lines in the Dockerfile to install node. Then I expose the ports 80:80 and 5173:5137 in docker-compose.yml. I configure vite like this:

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

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/js/app.js'],
            refresh: true
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false
                }
            }
        })
    ],
    server: {
        host: '0.0.0.0',
        port: 5173,
        hmr: {
            port: 5173,
            clientPort: 5173,
            host: 'localhost'
        }
    }
});
Enter fullscreen mode Exit fullscreen mode

And then I simply run npx vite inside the php:8.1-apache container. I tried everything I could think of but I cannot get this to work! Is it possible that apache blocks this somehow?

cors Article's
30 articles in total
Favicon
Cookies auto clearing after browser refresh issue , CORS related express cookies issue
Favicon
What is CORS Error and how to fix it
Favicon
CORS in Spring Boot with Kotlin
Favicon
Understanding CORS: Why Your API Requests Are Failing 🚧
Favicon
How to Launch Google Chrome Without CORS Protection on macOS
Favicon
Cross-Origin Resource Sharing (CORS): A Comprehensive Guide
Favicon
CORS is Stupid
Favicon
roadauth-rails api jwt cors 2024
Favicon
What is the CORS ?
Favicon
Fixing CORS in your SPA
Favicon
Advanced CORS: Deep Dive into Cross-Origin Resource Sharing
Favicon
Third-Party Cookies Are Gone (Or Not). How Can I Still Embed Cross-Site Apps?
Favicon
SOLVING CORS ERROR
Favicon
Troubleshooting CORS Issues in Express.js: A Simple Misconfiguration
Favicon
Implementing CORS in a Custom Next.js Server
Favicon
What are CORS? and how to configure it in Node?
Favicon
Brewing a More Open Web: CORS Demystified
Favicon
CORS Error Explained and How to Fix It?
Favicon
Resolving CORS Issues in express Node.js Project
Favicon
Resolving Firebase Authentication Sign-in Method Error
Favicon
Problem Encountered with CORS in Deno Server
Favicon
Solving CORS errors with Appwrite
Favicon
Need Help: Cross-Origin-Opener-Policy Blocking Google Login Window.Closed Call
Favicon
Understanding CORS, CSRF attacks and enabling valid CORS
Favicon
Enabling CORS in a .NET Core Server-Side Application
Favicon
[SOLVED]Yet another docker + vite, The connection was reset
Favicon
Cross-Origin Resource Sharing (CORS)
Favicon
Modern API development(Part 2): Initialize Server
Favicon
Configurando CORS Global para API Springboot
Favicon
Understand CORS 🌐 in Easy Way🦾

Featured ones: