'How to conditionally alias a set of urls in next.js

I have a website built in next.js at https://graphjson.com which has an api available at /api/**. So for instance the log endpoint is graphjson.com/api/log

But I also have the subdomain api.graphjson.com, which is the same next.js app hosted on render. I want it such that when on render, you can simply log via api.graphjson.com/log.

Is it possible to alias the set of /api/** routes to /** but only on certain deploy targets?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source