Laravel Inertia Vite
P粉262926195
P粉262926195 2024-01-16 11:21:07
0
1
465

In production mode (on the server), my website gets the error in the Chrome console:

Uncaught (Promise) Error: Page not found: ./Pages/Posts/Show.vue

Additionally, the dashboard page does not update based on changes to the text and new pagination table that I introduced in local development.

Everything is fine locally, but pushing to Digital Ocean Server does not show the latest changes.

I checked the source code online and their original code is there. I can see the text, pagination table, and new routes changing. But they don't show up when I load the site. I suspect something to do with caching or the build process?

I've done it:

php artisan cache:clear

php artisan configuration: clear

php artisan view: clear

npm run build(new vite version assets)

Can anyone help?

shared documents:

Resources/js/app.js

import './bootstrap';
import '../css/app.css';

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(ZiggyVue, Ziggy)
            .mount(el);
    },
});

InertiaProgress.init({ color: '#4B5563' });

Post controller

<?php

namespace AppHttpControllersPost;

use AppHttpControllersController;
use IlluminateHttpRequest;
use InertiaInertia;
use AppModelsPost;

class PostController extends Controller
{
    /**
     * Display all posts
     *
     * @return InertiaResponse
     */
    public function index(Request $request)
    {
        $posts = Post::paginate(10);
        
        return Inertia::render('Dashboard', ['posts' => $posts]);
    }


    /**
     * Display a post
     *
     * @return InertiaResponse
     */
    public function show(Request $request, $id)
    {
        $post = Post::findOrFail($id);

        return Inertia::render('Posts/Show', ['post' => $post]);
    }    
}

P粉262926195
P粉262926195

reply all(1)
P粉511985082

This is a docker/nginx issue. Files generated by the application are not routed correctly, so static files from the original version are not replaced.

I switched to using volumes to sync data between containers and it worked.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!