Laravel 9 + Vite behind nginx-proxy container
I'm having trouble getting a fresh instance of laravel set up behing my ngingx-proxy container on my local machine. I use Windows 10, WSL2 and Docker.
I use a star cert for a domain I own on my nginx-proxy to separate my different development environments. This allows me to have multiple dev domains running over https on my local box. Note: I exposed 5173 for vite.
version: "3"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- 80:80
- 443:443
- 5173:5173
volumes:
- ./.docker/certs:/etc/nginx/certs
- /var/run/docker.sock:/tmp/docker.sock:ro
networks:
default:
name: nginx-proxy
external: true
On my laravel box I use the following configuration to hook into nginx-proxy:
expose:
- 80
- 5173
environment:
VIRTUAL_HOST: subdomain.mydomain.com
VIRTUAL_PORT: 5173
It's my first time using vite, but it seems that it overwrites all resource links with what ever is defined in the vite.config.js. I want vite to serve the files using http and let nginx-proxy handle the SSL aspect because I already have that configured. I updated ````vite.config.js``` as follows:
const host = 'subdomain.mydomain.com';
export default defineConfig({
server: {
host,
hmr: {
host: host,
},
https: true,
}, ...
I logged into the laravel box an installed laravel breeze. I run npm run dev. I can get to my homepage at https://subdomain.mydomain.com just fine, but when I go the /register page in my console it states
The Same Origin Policy disallows reading the remote resource at https://subdomain.mydomain.com:5173/@vite/client. (Reason: CORS request did not succeed)
If i disable the https: true then I get a different error stating I'm trying to serve insecure content to a secure site.
Any assistance would help.
Please or to participate in this conversation.