I’ve got it working by specifying an absolute url. Is there a generic hostname that can be used so that the rewrite doesn’t have to know in advance what domain it’s being deployed to?
Hi @thor1 , glad you got the url working. I’m not aware of specific domain deployments in a rewrite. Perhaps you can find something of use in this article?
I assume it doesn’t work with a relative url, due to the target url being a nuxt /api/* url, this is implemented as a netlify function. Does relative rewrites not work with netlify functions?
I can write a handler that takes anything eg at /~/* and rewrites or redirects to a nuxt api endpoint such as /api/media/some/media/path.jpg and then i do an internal lookup against a mapping to find the new url. It works with 301, but not with 200. That’s why I though that maybe rewrites doesn’t work with netlify functions
There’s no file at that location no, the /api/* endpoints with nuxt are implemented as serverside endpoints, and netlify has special support for nuxt serverside endpoint implementing them as functions.
That’ll explain why I’ve been a bit confused, as I don’t use nuxt myself and I thought that you were asking a more general question about Netlify redirects.
From what little I do know, I believe you’re correct and that there is middleware that generates serverless functions on your behalf. It’s likely it’s also capable of creating redirects/rewrites.
I don’t know how anything that’s automatically generated interacts with everything else, but the Netlify support team should be able to provide more insight.