Problem 404 css/js files in my Laravel APP php+vite #1296
-
SummaryHello, I configured the vercel file with the recommendations for Laravel, but I have 404 errors on my files. Knowing that I use both PHP for Laravel but also Vite to create a react app in Laravel. I attach part of the file. So the URLs are like this: /build/assets/app.f9081f27.css But on the source I see the attached screen, I don't have a build folder, I think that's what is causing the problem. Locally and in the vercel build, I see the files being created in the public/build/assets folder using "npm run build". Additional information
ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 20 replies
-
I haven't found a solution yet, but i would bé vert interested ! |
Beta Was this translation helpful? Give feedback.
-
Do you use a preset framework in the configuration of your Vercel project on Vercel? |
Beta Was this translation helpful? Give feedback.
-
I still have 2 problems, the mixed content http / https and my files are present in the right folder on Vercel, but they come out in 404 |
Beta Was this translation helpful? Give feedback.
-
@NicolasKulka Could you please update the current status? What are the remaining issues? Also, please create a minimal reproducible example repository and share the link: |
Beta Was this translation helpful? Give feedback.
-
@smaeda-ks Reproduce here => https://ecommerce-indol-tau.vercel.app/ 1 - Mixed content : http / https, Why ? 2 - I have a 404 on all files, however the build folder is present in the Source > "Output" files that can be seen on the Vercel application, Why ? |
Beta Was this translation helpful? Give feedback.
-
@NicolasKulka @josetorronteras |
Beta Was this translation helpful? Give feedback.
-
Hi devs, so I found a solution that works for me. It's pattern matching the url of the css and js to know where to look for it in the application folder. "routes": [ |
Beta Was this translation helpful? Give feedback.
-
@NsonguruaJohnson
|
Beta Was this translation helpful? Give feedback.
-
Hello @NicolasKulka , I have finally got my Laravel + Vite webapp working on Vercel. Github Repo: vercel.json In my routes on vercel.json The src value is my Vercel webapp output src: /build/(.*) means everything on /build Vercel output folder is passed to dest With these sequence/pattern, I can even put my images in my public/resources folder and reference that in Vercel src. For example below: I hope I conveyed my message properly. Lemme know anything else you have questions with. Please correct me if I'm wrong on this. Thank you everyone for the help |
Beta Was this translation helpful? Give feedback.
-
@Jeppenseppiro It's ok now for me, thanks a lot. But i have a last problem : |
Beta Was this translation helpful? Give feedback.
-
Hi, I have the same issue with 404 error despite your solutions. My vercel configuration: {
"version": 2,
"functions": {
"api/index.php": {
"runtime": "vercel-php@0.5.2"
}
},
"routes": [
{
"src": "/build(.)",
"dest": "/public/assets/"
},
{
"src": "/favicon/(.*)",
"dest": "/public/favicon/"
},
{
"src": "/(.*)",
"dest": "/api/index.php"
}
],
"env": {
"APP_ENV": "production",
"APP_CONFIG_CACHE": "/tmp/config.php",
"APP_EVENTS_CACHE": "/tmp/events.php",
"APP_PACKAGES_CACHE": "/tmp/packages.php",
"APP_ROUTES_CACHE": "/tmp/routes.php",
"APP_SERVICES_CACHE": "/tmp/services.php",
"VIEW_COMPILED_PATH": "/tmp",
"CACHE_DRIVER": "array",
"LOG_CHANNEL": "stderr",
"SESSION_DRIVER": "cookie"
}
} Build and development settings: And the Output source after deployment: Can you have an idea ? Thx. |
Beta Was this translation helpful? Give feedback.
-
Resumo: NÃO USEM VERCEL COM NADA QUE ELA NÃO DÊ DE MÃO BEIJADA |
Beta Was this translation helpful? Give feedback.
-
XHRPOST { login and registration working |
Beta Was this translation helpful? Give feedback.
-
i know this is an old post but i hit a wall and cannot deploy my project with vercel. Below it my vercel.json file and the error i get. `{
}` |
Beta Was this translation helpful? Give feedback.
Hello @NicolasKulka , I have finally got my Laravel + Vite webapp working on Vercel.
Thanks to @NsonguruaJohnson for the idea regarding the build routes and I have reconfigured it to my liking.
Github Repo: vercel.json
Vercel webapp: Tempestas
In my routes on vercel.json
"routes": [ { "src": "/build/(.*)", "dest": "/public/build/" }, { "src": "/(.*)", "dest": "/api/index.php" } ],
The src value is my Vercel webapp output
The dest is the Laravel directory
src: /build/(.*) means everything on /build Vercel output folder is passed to dest
dest: /public/build/ means Laravel directory and the src is passed here
With these sequence/pattern, I can even put my images in my public/resources folder…