I'm implementing an OAuth flow with Google and need a route that'll receive a POST request with the credentials payload. I have this currently working with an api route, but during payload verification some errors can throw that I want to present a nice UI for using the Error Boundaries I have for the rest of the application. I want to just have a regular route, but unsure how to access the form data from within either the loader or a server function.
In Remix/React Router, I could do this very easily like so:
// Handles the POST request from the Google OAuth callback
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
...
return redirect(state.redirect ?? '/', {
headers,
});
}
export default function GoogleSignInPage() {
// expect a server-side redirect, but should render errors using Error Boundaries
return null;
}