How can I resolve routes by name from API side?

Hi, I’m not sure if this is possible, but I’d like to resolve the URL of a route from the api side.
Basically, I have this route:

<Route path="/dashboard/{id}" page={DashboardPage} name="dashboard" />

and I want to resolve the route from a service with this:

// api/src/services/dashboards/dashboard.js

import { routes } from '@redwoodjs/router'
    id: '12345'

But this code does not work. How should I resolve this on server side?

Can you explain more about what you are looking to do rather than how?

The api and web sides are distinct — there is no concept of a router in the api.

Are you trying to have a service that “does something” given the is viewing dashboard with id 12345” and something else if id 6789?

This is my use case:

  1. I have a page with a form where I ask for an email.
  2. When someone enters his/her email, the server creates a dashboard using a uuid (e.g. http://mydomain/dashboard/fa9c607b-7288-4e10-b477-675e1f092e7c
  3. The backend sends the link with the dashboard URL to the email of step 1.

So, this use case is basically a way of login without creating username+password.

  • The logic of creating URLs must be on the server, not the front-end.
  • I’d like to be able to get URL via the routes names for DRY reasons.

there is no concept of a router in the api.

OK, that responded to my question, but why not? The ability of resolving routes by its names is not only a “web” concern.