I am wondering what does Redwood provide to handle URLs/routes on the API side, and how both sides can actually safely reference each other’s routes.
My situation:
one custom serverless function that is a redirect target in a flow with a 3rd party
on the web side, a component that initiates that flow to the 3rd party
To initiate the flow, a URL with a redirect_uri query string parameter must be generated.
To make things clean, I would like to avoid hard-coding the function URL in my component.
Is there a way for my web side to do this? Something like api.routes.myFunctionName()?
AFAIK, there isn’t even a way to do that within the API side itself?
Secondly, in that function I will handle the return code for that 3rd party flow, and depending on the result I want to redirect users to a different page on my web side.
Once again, I’d rather not hard-code those redirect URLs in my function code.
Is there a way for my function to reference the web side routes?
There currently isn’t a way to do exactly what you’re looking for. The Api and web sides are fairly isolated, and is something we will only look to address in v2.
Here’s a couple of other ways though:
Use an env var to set your AUTH_REDIRECT_URL so you don’t need to hardcode