Adjust Auth Callback URL for self-hosted instances (#167)
* Adjust URL for local development during auth callback covering more scenarios * Fix typechecking issues
This commit is contained in:
committed by
GitHub
parent
9a503412e5
commit
0478a6428d
@@ -73,7 +73,7 @@ function DeleteAccountForm() {
|
|||||||
const form = useForm({
|
const form = useForm({
|
||||||
resolver: zodResolver(DeletePersonalAccountSchema),
|
resolver: zodResolver(DeletePersonalAccountSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
confirmation: '',
|
confirmation: '' as 'DELETE'
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ function DeleteTeamConfirmationForm({
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
confirm: '',
|
name: ''
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ function LeaveTeamContainer(props: {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
confirmation: '',
|
confirmation: '' as 'LEAVE'
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,8 @@ class AuthCallbackService {
|
|||||||
|
|
||||||
const host = request.headers.get('host');
|
const host = request.headers.get('host');
|
||||||
|
|
||||||
// set the host to the request host since outside of Vercel it gets set as "localhost"
|
// set the host to the request host since outside of Vercel it gets set as "localhost" or "0.0.0.0"
|
||||||
if (url.host.includes('localhost:') && !host?.includes('localhost')) {
|
this.adjustUrlHostForLocalDevelopment(url, host);
|
||||||
url.host = host as string;
|
|
||||||
url.port = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
url.pathname = params.redirectPath;
|
url.pathname = params.redirectPath;
|
||||||
|
|
||||||
@@ -213,6 +210,25 @@ class AuthCallbackService {
|
|||||||
nextPath: nextUrl,
|
nextPath: nextUrl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private adjustUrlHostForLocalDevelopment(url: URL, host: string | null) {
|
||||||
|
if (this.isLocalhost(url.host) && !this.isLocalhost(host)) {
|
||||||
|
url.host = host as string;
|
||||||
|
url.port = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private isLocalhost(host: string | null) {
|
||||||
|
if (!host) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
host.includes('localhost:') ||
|
||||||
|
host.includes('0.0.0.0:') ||
|
||||||
|
host.includes('127.0.0.1:')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError({
|
function onError({
|
||||||
|
|||||||
Reference in New Issue
Block a user