mirror of
https://github.com/langgenius/dify.git
synced 2026-06-16 22:11:09 +08:00
fix(web): SSR crash on webapp-signin when redirect_url present
getShareCodeFromRedirectUrl read window.location.origin in the render path of WebAppStoreProvider; since the app-shell bootstrap refactor (#35394) this component server-renders, so any /webapp-signin visit with a redirect_url param threw "window is not defined" and returned a 500 error shell. That shell lacks the body dataset runtime env, so the client fell back to localhost API defaults and the page dead-ended. Parse with a placeholder base instead — only pathname is consumed.
This commit is contained in:
parent
49c97a3f61
commit
37a616d1f3
@ -55,7 +55,8 @@ export const useWebAppStore = create<WebAppStore>(set => ({
|
||||
const getShareCodeFromRedirectUrl = (redirectUrl: string | null): string | null => {
|
||||
if (!redirectUrl || redirectUrl.length === 0)
|
||||
return null
|
||||
const url = new URL(`${window.location.origin}${decodeURIComponent(redirectUrl)}`)
|
||||
// base only anchors relative-path parsing; never read back (SSR-safe)
|
||||
const url = new URL(decodeURIComponent(redirectUrl), 'http://base.invalid')
|
||||
return url.pathname.split('/').pop() || null
|
||||
}
|
||||
const getShareCodeFromPathname = (pathname: string): string | null => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user