diff --git a/pages/api/oauth/authorize.ts b/pages/api/oauth/authorize.ts index 8fd277580..6911101bc 100644 --- a/pages/api/oauth/authorize.ts +++ b/pages/api/oauth/authorize.ts @@ -25,7 +25,9 @@ export default async function handler( }); } } catch (err: any) { - res.status(500).json({ error: { message: err.message } }); + const message = err.message || 'Something went wrong'; + const status = err.status || 500; + res.status(status).json({ error: { message } }); } } diff --git a/pages/api/oauth/saml.ts b/pages/api/oauth/saml.ts index f837bd3ad..99943fd4b 100644 --- a/pages/api/oauth/saml.ts +++ b/pages/api/oauth/saml.ts @@ -19,8 +19,10 @@ export default async function handler( }); } } catch (err: any) { - // TODO: Handle error - console.error('saml error:', err); + const message = err.message || 'Something went wrong'; + const status = err.status || 500; + + res.status(status).json({ error: { message } }); } } diff --git a/pages/api/oauth/token.ts b/pages/api/oauth/token.ts index 6d68d5bc2..cb4cf232c 100644 --- a/pages/api/oauth/token.ts +++ b/pages/api/oauth/token.ts @@ -19,8 +19,10 @@ export default async function handler( }); } } catch (err: any) { - // TODO: Handle error - console.error('token error:', err); + const message = err.message || 'Something went wrong'; + const status = err.status || 500; + + res.status(status).json({ error: { message } }); } }