-
Notifications
You must be signed in to change notification settings - Fork 519
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
Use appName directly from .env in <title> #292
Conversation
@@ -4,7 +4,7 @@ import createServer from '@inertiajs/react/server'; | |||
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; | |||
import route from '../../vendor/tightenco/ziggy/dist/index.m'; | |||
|
|||
const appName = 'Laravel'; | |||
const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssr can also use process.env
to access envs (even without the VITE_
prefix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that it is consistent and uses VITE_APP_NAME
, otherwise if you remove that ENV it could work in SSR and not a normal build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Using process.env
would be a good example of accessing secrets/api keys and not exposing them to the frontend, but using it here would be a little misleading
Tests fail here. |
I've created a fix for the TS failure here: #293 It is unrelated to this PR. |
Currently,
appName
in app.tsx is pulled via DOM from app.blade.php <title> tag. It works, but using it from .env seems like a better approach. Additionally, it serves as an example of how .env variables should be accessed in React/Vue.The
ssr
templates had'Laravel'
hardcoded as the app name, which is not great for SEO. Replaced those parts withimport.meta.env.VITE_APP_NAME
as well.This depends on laravel/laravel#6204 where I added
VITE_APP_NAME
as an alias toAPP_NAME
I don't think any changes in this PR could be considered breaking.
Similar issue fixed in Jetstream: laravel/jetstream#1329