sdekna
04/09/2023, 6:18 AMsupertokens-web-js
sdk with sveltekit... it is working properly, however, after a user successfully signs in, I am getting this error: 500 url.clone is not a function
My init function:
js
export function init_supertoken_auth() {
try {
SuperTokens.init({
appInfo: {
apiDomain: "....",
apiBasePath: "/",
appName: "....",
},
recipeList: [
Session.init(),
ThirdPartyEmailPassword.init(),
],
enableDebugLogs: true,
});
} catch (error) {
console.log({ error })
}
}
And my sign in function looks like this:
js
export async function sign_in_handler(event) {
try {
const raw_form_data = new FormData(event.target);
const email = raw_form_data.get('email') as string;
const password = raw_form_data.get('password') as string;
const response = await emailPasswordSignIn({
formFields: [
{
id: 'email',
value: email
},
{
id: 'password',
value: password
}
],
});
if (response.status === 'FIELD_ERROR') {
response.formFields.forEach((formField) => {
if (formField.id === 'email') {
// Email validation failed (for example incorrect email syntax).
console.log(formField.error)
}
});
} else if (response.status === 'WRONG_CREDENTIALS_ERROR') {
console.log('Email password combination is incorrect.')
} else {
// sign in successful. The session tokens are automatically handled by
// the frontend SDK.
console.log('sign in success')
await post_sign_in_flow()
}
} catch (error: any) {
if (error.isSuperTokensGeneralError === true) {
// this may be a custom error message sent from the API by you.
console.log(error.message)
} else {
console.log(error)
}
}
}
How do I prevent the url clone? the sign in works and session is initiated properly.rp
04/09/2023, 6:30 AMsdekna
04/09/2023, 6:31 AMrp
04/09/2023, 6:33 AMsdekna
04/09/2023, 6:37 AMpost_sign_in()
function only makes some user redirection logic... which works but until the redirect inside the post_sign_in()
function fires I see the 500 url.clone is not a function
errorrp
04/09/2023, 6:38 AMsdekna
04/09/2023, 7:07 AMjs
export async function sign_in_handler(event) {
try {
const response = await emailPasswordSignIn({
formFields: [
{
id: 'email',
value: email
},
{
id: 'password',
value: password
}
],
});
console.trace(response);
if (response.status === 'FIELD_ERROR') {
response.formFields.forEach((formField) => {
if (formField.id === 'email') {
console.log(formField.error)
}
});
} else if (response.status === 'WRONG_CREDENTIALS_ERROR') {
console.log('Email password combination is incorrect.')
} else {
// sign in successful. The session tokens are automatically handled by
// the frontend SDK.
console.log('sign in success')
console.log('1')
await post_sign_in_flow()
console.log('2')
}
} catch (error: any) {
// ....
}
}
I do not get any errors logged in the console, only shown in the page... console tracing the response object give this:https://cdn.discordapp.com/attachments/1094506506864562206/1094518887594328075/Screenshot_from_2023-04-09_08-58-50.png▾
rp
04/09/2023, 7:07 AMsdekna
04/09/2023, 7:13 AMhttps://cdn.discordapp.com/attachments/1094506506864562206/1094520351687458916/Peek_2023-04-09_09-12.gif▾
rp
04/09/2023, 7:17 AMsdekna
04/09/2023, 7:22 AMrp
04/09/2023, 7:23 AMsdekna
04/09/2023, 7:40 AMmethod="POST"
which somehow invoked this behaviour... once I removed the method="POST"
the problem disappeared.
Thanks for the help again.