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

dwissmann's avatar

Resources not on same port

I believe I have a very similar problem - I setup a brand new laravel - inertia - Vue environment by following all the docs, then I run npr run dev and get following: ➜ Local: ----127.0.0.1:5173/ ➜ Network: use --host to expose

LARAVEL v9.35.1 plugin v0.6.1

➜ APP_URL: ----localhost

I learned that the app werbserver isn't running so I run php artisan serve and get: php artisan serve

INFO Server running on [----127.0.0.1:8000].

I go to that URL and it serves the page without the resources - my console has following errors:

 127.0.0.1/:6 GET ----/127.0.0.1:5173/css/app.css net::ERR_ABORTED 404 (Not Found) 127.0.0.1/:7 GET ----127.0.0.1:5173/js/app.js net::ERR_ABORTED 404 (Not Found)

(---- placehodler for protocol since I can't post urls) How can I fix this without hacking my environment?

both servers are running - I can go to 127.0.0.1:5173 and see the default page for Vite but when I go to localhost I get the forbidden response - when I go to 127.0.0.1:8000 I get my app but my resources are not loading

0 likes
29 replies
Sinnbeck's avatar

Ok first of all try stopping npm run dev and run npm run build instead. Does the page itself work now ?

1 like
dwissmann's avatar

good lord - I feel like an idiot - maybe the docs could be just a bit more explicit about that - it works like charm - Thank you so much for this very quick and accurate response. Have a great day

Sinnbeck's avatar

@dwissmann Wait. It is only to compile once. The dev server is needed if you are going to be working with vue/inerita or similar. Otherwise you need to run npm run build after every little change.

Try running npm run dev again and see if it breaks again.

dwissmann's avatar

it sure does - does that mean I need to run npm run build after each change?

Sinnbeck's avatar

@dwissmann You can but I would think that you would go crazy after week. It is better to spend a bit of time getting the dev server working together with php artisan serve.

Now a weird thing I noticed is that your urls seem wrong. Can you show how you are adding the vite helper in your layout?

Something like this

@vite(['foobar.js'])
dwissmann's avatar

@Sinnbeck - again, I JUST installed a brand new environment and did not add any "vite helper" - shouldn't that be included in a brand new install / new build?

dwissmann's avatar

In fact upon further inspection when I run npm run build I get php error "Mix manifest not found at ...." and the question if I "forgot to run npm install && npm run dev - strange - the docs don't talk about that.

Sinnbeck's avatar

@dwissmann Oh! Is this is an existing project running mix instead of vite? Are you currently converting it to vite?

dwissmann's avatar

@Sinnbeck - no totally brand new - used a different Mac to have a new environment by following strictly all the docs.

Sinnbeck's avatar

@dwissmann Can you show your package.json? And also your layout file where you are loading vite/mix ?

dwissmann's avatar

package.json:

{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build"
    },
    "devDependencies": {
        "axios": "^0.27",
        "laravel-vite-plugin": "^0.6.0",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "vite": "^3.0.0"
    },
    "dependencies": {
        "@inertiajs/inertia": "^0.11.1",
        "@inertiajs/inertia-vue3": "^0.6.0",
        "vue": "^3.2.36"
    }
}

don't think I have a layout file - I have a vite.config.js: import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});
Sinnbeck's avatar

@dwissmann Those both look correct. Can you get that error back you had before with the missing mix manifest, and then share the error (there is a share button on the error page)

Btw. You can format your code by adding ``` on the line before and after it

1 like
dwissmann's avatar

does that work:

//flareapp.io/share/w5BOdndm#F61
Sinnbeck's avatar

@dwissmann Yup. Check this link https://flareapp.io/share/w5BOdndm#F59

As you can see it has mix() in "resources/views/app.blade.php". That is the old js/css builder. I have no clue how that got into a new laravel install

Replace the two mix lines with

@vite(['resources/css/app.css', 'resources/js/app.js'])

Now it should start working

dwissmann's avatar

@Sinnbeck That is what I was wondering too but I thought it must be correct since I just created a brand new "vanilla" environment and created a new project.

So I replace following:

<link href="{{ mix('/css/app.css') }}" rel="stylesheet" />
    <script src="{{ mix('/js/app.js') }}" defer></script>

with

@vite(['resources/css/app.css', 'resources/js/app.js'])

then ran npm run build but there are js errors now

dwissmann's avatar

@Sinnbeck here is the error:

app.b977315c.js:8 Uncaught (in promise) ReferenceError: require is not defined
    at resolve (app.b977315c.js:8:37267)
    at p (app.b977315c.js:8:36724)
    at ld (app.b977315c.js:8:36798)
    at app.b977315c.js:8:37252
dwissmann's avatar

@Sinnbeck

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'

createInertiaApp({
    resolve: name => require(`./Pages/${name}`),
    setup({ el, App, props, plugin }) {
        createApp({ render: () => h(App, props) })
            .use(plugin)
            .mount(el)
    },
})
Sinnbeck's avatar

@dwissmann That should have been

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
 
createInertiaApp({
  resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .mount(el)
  },
});

https://laravel.com/docs/9.x/vite#inertia

dwissmann's avatar

Should I just start from scratch? For a 'documented' fresh install it seems to run into a ton of bumps

Sinnbeck's avatar

@dwissmann Yeah I have no clue how it ended up in that state. What command did you run to get it started?

Personally I would do

composer create-project laravel/laravel my-super-project
Sinnbeck's avatar

@dwissmann :D Well try it again, and see if those files look correct from the start :) Be aware that you might have gotten into trouble if you were following the guide on https://inertiajs.com/ as it is a bit dated.

dwissmann's avatar

Ok, so I am starting from scratch and now I see where I got the "mix" - directly from the inertia web site - so the two aren't in synch

Sinnbeck's avatar

@dwissmann yeah sadly it haven't been updated to vite yet. Use the laravel website I linked to above instead. And ask away if you have any problems

1 like
dwissmann's avatar

just for the kick of it, I installed breeze - this will get me going the correct way - I'll hit this site if I have more question - but breeze is now working as expected and I can learn the new scaffolding and vue etc. thanks again.

Please or to participate in this conversation.