holloway
A route that returns either txt/xml (server route) or Vue (pages route)?
I'm replacing a legacy site with a particular URL structure that I need to maintain. Unfortunately the Nuxt route patterns aren't expressive enough and I can't find a workaround. The paths I want to maintain are
/rfc/rfc1.xml
as a server route, and /rfc/rfc1
as a pages Vue route. The filename-pattern in the server
or pages
directory would be [id].ts
but then Nuxt prefers the server route over pages, and there's no way to narrow the server route with patterns like [id].xml.ts
(note the ".xml"). Returning a string of HTML from the server route could work but Nuxt 3 removed nuxt.renderRoute()
which existed in Nuxt 2, so how would I even render a route to HTML so that I could return in the server route. I've also looked at middleware to handle routing but I don't want to redirect and change the legacy URL structure.5 replies
Wildcard routes that vary by file extension that Nuxt interprets as overlapping routes
I'm replacing a site with two server routes at
/rfc/rfcN.json
and /rfc/rfcN.txt
and an HTML route at /rfc/rfcN/
where the N
is a number. Making files in server/routes/rfc/
named [id].txt.ts
and [id].json.ts
doesn't result in Nuxt serving each route distinctly. Should I use a single route file that handles them all (if so how do I handle server and vue routes?), or middleware to redirect, or what?6 replies