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({
|
||||
resolver: zodResolver(DeletePersonalAccountSchema),
|
||||
defaultValues: {
|
||||
confirmation: '',
|
||||
confirmation: '' as 'DELETE'
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ function DeleteTeamConfirmationForm({
|
||||
}),
|
||||
),
|
||||
defaultValues: {
|
||||
confirm: '',
|
||||
name: ''
|
||||
},
|
||||
});
|
||||
|
||||
@@ -260,7 +260,7 @@ function LeaveTeamContainer(props: {
|
||||
}),
|
||||
),
|
||||
defaultValues: {
|
||||
confirmation: '',
|
||||
confirmation: '' as 'LEAVE'
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -42,11 +42,8 @@ class AuthCallbackService {
|
||||
|
||||
const host = request.headers.get('host');
|
||||
|
||||
// set the host to the request host since outside of Vercel it gets set as "localhost"
|
||||
if (url.host.includes('localhost:') && !host?.includes('localhost')) {
|
||||
url.host = host as string;
|
||||
url.port = '';
|
||||
}
|
||||
// set the host to the request host since outside of Vercel it gets set as "localhost" or "0.0.0.0"
|
||||
this.adjustUrlHostForLocalDevelopment(url, host);
|
||||
|
||||
url.pathname = params.redirectPath;
|
||||
|
||||
@@ -213,6 +210,25 @@ class AuthCallbackService {
|
||||
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({
|
||||
|
||||
Reference in New Issue
Block a user