-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix(start-basic): Add deploy url to fix SSR fetch bug #7098
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,3 +3,5 @@ export type User = { | |||||||||
| name: string | ||||||||||
| email: string | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export const DEPLOY_URL = 'http://localhost:3000' | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n examples/react/start-basic/src/utils/users.tsxRepository: TanStack/router Length of output: 225 🏁 Script executed: rg -n "import.*DEPLOY_URL" examples/react/start-basic/src/Repository: TanStack/router Length of output: 254 🏁 Script executed: rg -n "DEPLOY_URL" examples/react/start-basic/src/ -A 2 -B 2Repository: TanStack/router Length of output: 2000 🏁 Script executed: cat -n examples/react/start-basic/src/routes/users.tsx | head -50Repository: TanStack/router Length of output: 1701 🏁 Script executed: cat -n examples/react/start-basic/src/routes/users.\$userId.tsx | head -50Repository: TanStack/router Length of output: 1612 🏁 Script executed: fd "vite.config" examples/react/start-basic/ || fd "\.env" examples/react/start-basic/Repository: TanStack/router Length of output: 100 🏁 Script executed: cat -n examples/react/start-basic/vite.config.tsRepository: TanStack/router Length of output: 670 🏁 Script executed: fd "\.env" examples/react/start-basic/ -type fRepository: TanStack/router Length of output: 229 🏁 Script executed: cat -n examples/react/start-basic/.env 2>/dev/null || echo "No .env file found"Repository: TanStack/router Length of output: 77 Don't hardcode Line 7 forces all SSR loaders to fetch from Use an environment variable with a sensible development default: Proposed fix export type User = {
id: number
name: string
email: string
}
-export const DEPLOY_URL = 'http://localhost:3000'
+const envDeployUrl = import.meta.env.VITE_DEPLOY_URL?.trim()
+
+export const DEPLOY_URL = (envDeployUrl || 'http://localhost:3000').replace(/\/+$/, '')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
cat -n examples/react/start-basic/src/routes/users.\$userId.tsxRepository: TanStack/router
Length of output: 1612
Encode
userIdbefore building the request path.Line 10 concatenates raw
userIdinto the URL path. If it contains reserved characters like/,?, or#, the request target will be malformed.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents