Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while using Inertia Vue: The Vite server should not be accessed directly. #96

Closed
Bosphoramus opened this issue Jul 20, 2022 · 3 comments · Fixed by #98
Closed

Comments

@Bosphoramus
Copy link

  • Laravel Vite Plugin Version: 0.5.0
  • Laravel Version: 9.21.0
  • Node Version: 16.15.0
  • NPM Version: 8.14.0
  • Host operating system: macOS 12.4
  • Web Browser & Version: Chrome 103
  • Running in Sail / Docker: No

Description:

I have scaffolded an Inertia Vue SSR application using Laravel breeze with the following breeze command:

php artisan breeze:install vue --ssr

Everything works correctly but there is a little bug that bothers me, almost all the time, when i start the dev server i get the following warning in the console: The Vite server should not be accessed directly. Your Laravel application's configured APP_URL is: X

Im not accessing the vite dev server url, im using Laravel Valet and im accessing the "fancy" vhost url.

Steps To Reproduce:

Install Laravel and enter the directory:

laravel new test && cd test

Require Breeze

composer require laravel/breeze

Scaffold a Breeze Inertia Vue SSR app using

php artisan breeze:install vue --ssr

Run the dev server

npm install && npm run dev

Go to your app

Using your web browser navigate to your app, usually the APP_URL that the dev server suggests

Stop the dev server

WITHOUT CLOSING YOUR APP TAB ON YOUR BROWSER Ctrl + c on the console, to close the dev server

Start it again

npm run dev

Now you should be seeing the warning, which shouldnt be showing because the user never accesed the dev server URL directly

Just noticed this also happens scaffolding the Breeze Vue Inertia application without SSR.

@Bosphoramus Bosphoramus changed the title Error using Inertia SSR: The Vite server should not be accessed directly. Error while using Inertia Vue: The Vite server should not be accessed directly. Jul 20, 2022
@jessarcher
Copy link
Member

I believe this is because Vite 3 now pings the root URL when the HMR server disappears.

It's a bit hard to reliably detect whether the user is visiting it vs. it being pinged by the Vite client, as the requests are both made by the browser.

I'm inclined to remove the console warning as the index page we serve should hopefully be enough to guide users towards running a dev server for Laravel.

@jessarcher
Copy link
Member

I've created #98 to address this. Feel free to continue discussion over there 🙂

@Bosphoramus
Copy link
Author

Ok, thank you @jessarcher ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants