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

chrismartinez99's avatar

Please help with weird loading issue!

I have a weird issue where when I click on the home ("welcome") route, it loads the route in an iframe:

Screen-Shot-2021-10-26-at-9-43-53-AM

This doesn't occur in development, so I updated my ENV variables on the server to reflect local development: APP_ENV=local APP_DEBUG=true and have cleared the cache.

This is the Route:

Route::get('/', [ContestantController::class,'welcome'])->name('welcome');

and here is the Controller

    public function welcome()
    {
        $contest_open = isContestOpen();

        return Inertia::render( 'Welcome', [
            'contest_open' => $contest_open
        ] );
    }

I am open to suggestions as to how to fix this. Please let me know if you need additional information.

0 likes
19 replies
Tray2's avatar

Show us the view file and the layout file.

Sound to me like you need to tell the code where to render the content somehow.

chrismartinez99's avatar

@karlm89 To honest, I'm newish to Laravel - I haven't used it since version 5, but I have ran artisan route:clear and the problem still persists.

chrismartinez99's avatar

This is the entire Welcome component:

import React from 'react';
import Members from '@/Layouts/Members'
import RulesContent from '@/Content/RulesContent'
import { InertiaLink, Head } from '@inertiajs/inertia-react';
import FlashMessages from '@/newComponents/FlashMessages';


export default function Welcome(props) {

    const flash        = props.flash
    const contest_open = props.contest_open
    const the_title    = 'Welcome | ' + props.appName

    const the_content = () => {
        if (!contest_open) {
            return (<p className="font-bold">The {props.appName} is not available at this time.</p>)
        }
        else {
            if ((flash.success || flash.error)) {
                return (<FlashMessages/>)
            }
            else {
                return (<InertiaLink
                    className="button button-green"
                    href={route('signup')}
                    headers={{ 'pec-valid-path': 'welcome' }}
                >
                    <span>I have read and agree to the terms above.</span>
                </InertiaLink>)
            }
        }
    }

    return (
        <Members
            errors={props.errors}
            header={<h2 className="font-semibold text-xl text-gray-800 leading-tight">{props.appName}</h2>}>

            <Head title={the_title} />

            <div className="py-10 px-4">
                <RulesContent  />

                <div className="flex items-center justify-center my-6">
                    {the_content()}
                </div>


            </div>
        </Members>
    );
}

chrismartinez99's avatar

@Sinnbeck Yep. Well, the home link leads to "/" and rules leads to "/rules" - but both pages will contain the rules. If you click on the logo and the home link they both load in the iframe.

Sinnbeck's avatar

@chrismartinez99 just as a test. Can you make one of them link to this? Just to see if it's the url or the code

Route::get('/welcome', [ContestantController::class,'welcome'])->name('welcome2');
chrismartinez99's avatar

@Sinnbeck This is the createInertiaApp code:

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => require(`./Pages/${name}`),
    setup({ el, App, props }) {
        return render(<App {...props} />, el);
    },
});

Members.js is the main layout, and is used like so (this is from Rules.js since it's shorter):

export default function Rules (props) {

    const the_title = 'Contest Rules | ' + props.appName

    return (
        <Members
            errors={props.errors}
            header={<h2
                className="font-semibold text-xl text-gray-800 leading-tight">{props.appName}</h2>}>

            <Head title={the_title}/>

            <div className="py-10 px-4">
                <RulesContent />
            </div>
        </Members>
    )
}

I did try changing the variable, $contest_open = true;, but that didn't really help either. Let me know if you think I need to change the layout format. Thank you also for all of your help with this.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@chrismartinez99 Anytime. Yeah perhaps try implementing persistent layouts as explained in the docs. Or maybe you can install react dev tools to debug what is rendered

chrismartinez99's avatar

Note to anyone who comes across this discussion. This was not resolved; we changed direction to Livewire. BUT I think Inertia would have worked and the issues that I encountered were server related. We moved to Digital Ocean with Forge and other issues were resolved. I don't want to name the original hosting company, because I don't want to appear that I am bashing them. But I believe that they had caching issues that were not present on DO/Forge.

Sinnbeck's avatar

@chrismartinez99 I find that very likely. I have used inertia since it was released and never had any such issues :)

1 like

Please or to participate in this conversation.