Vercel: How to use routing like serve in v2

Created on 10 Nov 2018  路  1Comment  路  Source: vercel/vercel

Now v2 is lovely!

I'm considering a method to migrate from v1 to v2. I'm hosting a static site with serve on v1. And, using the default routing of serve. So, the start property of package.json for that project is as follows.

"start": "serve dist"

I do not know what to define for the routes property in v2 for routing like serve.
Should I create a server like index.js to run serve-handler's API and define the builds property as follows?

"builds": [ { "src": "index.js", "use": "@now/node-server" } ] }

Most helpful comment

I resolved this by routing which forwards all requests to dist.

{
    "version": 2,
    "builds": [{ "src": "dist/**", "use": "@now/static" }],
    "routes": [{ "src": "/(.*)", "dest": "/dist/$1" }]
}

Up to this time /foo responded to /foo.html, but I have not tried that the same routing is possible. I put /foo/index.html there.

>All comments

I resolved this by routing which forwards all requests to dist.

{
    "version": 2,
    "builds": [{ "src": "dist/**", "use": "@now/static" }],
    "routes": [{ "src": "/(.*)", "dest": "/dist/$1" }]
}

Up to this time /foo responded to /foo.html, but I have not tried that the same routing is possible. I put /foo/index.html there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koljakutschera picture koljakutschera  路  3Comments

pex picture pex  路  3Comments

erhankaradeniz picture erhankaradeniz  路  3Comments

markozxuu picture markozxuu  路  3Comments

anaisbetts picture anaisbetts  路  3Comments