Search code examples
deploymentnext.jsweb-deploymentvercel

Vercel: A project file dynamically changing for each domain?


I am building a project on Vercel, deployed to multiple subdomains. The code should be 99% the same, but I need to have a different manifest.json for each subdomain.

Is there a way to make the manifest.json file dynamic, based on the subdomain the user visits?

I thought perhaps NextJS rewrites could help, but I am not sure how to use them.


Solution

  • I wasn't able to figure out how to serve /manifest.json, but at least I can return a JSON file from a NextJS Serverless function at api/manifest like so:

    res.setHeader("Content-Type", "application/json;charset=utf-8");
    return res.send(manifestJSON);