update param name

Signed-off-by: Stephen Glass <stephen@stephen.glass>
This commit is contained in:
Stephen Glass
2024-07-28 23:28:13 -04:00
parent 40064678e0
commit 5d8649d775
3 changed files with 9 additions and 6 deletions
@@ -21,8 +21,8 @@ const ONE_MINUTE_MS = 60 * 1000;
const AUTH_ERROR_COOKIE = 'auth-error';
function configureAuthErrorCookie(redirectUrl: string, appOrigin: string) {
const { hostname: domain, pathname: path, protocol } = new URL(redirectUrl);
function configureAuthErrorCookie(apiUrl: string, appOrigin: string) {
const { hostname: domain, pathname: path, protocol } = new URL(apiUrl);
const secure = protocol === 'https:';
// For situations where the auth-backend is running on a
@@ -42,15 +42,15 @@ export function createAuthErrorCookie(
origin: string,
options: {
error: Error;
redirectUrl: string;
apiUrl: string;
},
) {
const { error, redirectUrl } = options;
const { error, apiUrl } = options;
const jsonData = serializeError(error);
res.cookie(AUTH_ERROR_COOKIE, jsonData, {
maxAge: ONE_MINUTE_MS,
httpOnly: true,
...configureAuthErrorCookie(redirectUrl, origin),
...configureAuthErrorCookie(apiUrl, origin),
});
}
@@ -254,7 +254,7 @@ export function createOAuthRouteHandlers<TProfile>(
if (state?.flow === 'redirect' && state?.redirectUrl) {
createAuthErrorCookie(res, state?.redirectUrl, {
error: { name, message },
redirectUrl: `${baseUrl}/.backstage/error`,
apiUrl: `${baseUrl}/.backstage/error`,
});
const redirectUrl = new URL(state.redirectUrl);