Search code examples
gosingle-page-applicationsveltebuffaloroutify

Is there a way to have Routify ignore certain URL paths?


We're using Go (Buffalo) to serve up both an API and the static assets for a Single-Page Application (SPA) that uses Svelte and Routify.

However, I'd like to have certain routes (e.g. "/auth/login") be ignored by Routify and instead go to the Go / Buffalo server, for handling those requests.

Is there a Routify setting for that?

I see the ignore build config, but that seems to be for telling Routify to ignore certain files when building the list of routes, not ignoring certain URL paths.

(If I have to, I might be able to get our /auth/login call to work as an XHR call, then actually manually redirect the browser based on the response, but it would be nicer/simpler to simply allow the browser to go to /auth/login directly.)


UPDATE: Apparently going to /auth/login directly (e.g. in a new tab) does what I want. It's just clicking a link in the SPA that gets intercepted by Routify. So my question still stands, though slightly altered:

Is there a way to tell Routify not to intercept links to certain URL paths, but to simply let the browser go to that URL (leaving the SPA)?


Solution

  • The target attribute on a link tag does what I was after. Hooray for finding the appropriate documentation!

    If you want to use anchor's default navigation behaviour you can do so by adding the target attribute.

    Routify will ignore all anchors with target attribute.

    Source: https://www.routify.dev/guide/navigation

    So in my case, I needed to do this:

    <a href="/auth/login" target="_self">Login</a>