MultiPaaS

Publish a static site

MultiPaaS can host your app's frontend, or any static site: HTML, JavaScript, CSS, images and other files, served as they are over HTTPS. Each environment already has a site URL, so there is no DNS to set up and no cloud account to create. A site runs no server code. Its pages call your application's generated API, and its users sign in as Add end-user sign-in describes.

The site commands need CLI 1.20.0 or later.

Publish your build

Build your app with its own build command, then publish the directory the build writes, such as dist/:

multipaas site deploy ./dist --app APP_ID

Publish only the build output, never your project's root: every file under the directory becomes public. A link under the directory is followed when it stays inside it. A link that leads outside the directory, points at nothing or loops is refused, and nothing is uploaded.

site deploy uploads every file, then publishes them as one deployment. A publish is atomic: each request is served entirely from the previous deployment or entirely from the new one, never a mix of the two. The command then waits until the site URL serves the new deployment, and prints that URL. With --json it prints {"deploymentId", "siteUrl", "fileCount", "totalBytes"}. When every environment has a live or disabled site of its own, none serves the application's site: siteUrl is then empty, and the command doesn't wait.

An agent connected to MultiPaaS over MCP can publish a site too, with no CLI: ask it to publish your build folder. It zips the folder, uploads the zip and publishes it. MultiPaaS then unpacks the zip and checks every file against the limits below, and the agent waits until the site is live. A zip can hold at most 100 MiB.

multipaas envs list --app APP_ID prints every environment's site URL: https://APP--CLIENT.multipaas.app for the default environment and https://ENV--APP--CLIENT.multipaas.app for any other.

The application's site and an environment's own

Without --env, site deploy publishes the application's site, unless multipaas.json names an environment, as below. Every environment serves it, each at its own site URL, unless the environment has a live site of its own, which it serves instead, or a disabled one, which serves nothing.

With --env, it publishes that environment's own site, which the environment serves instead of the application's. Use one to try a new build in a test environment while the other environments keep the application's site:

multipaas site deploy ./dist --app APP_ID --env ENV_ID

If your project's multipaas.json has an environmentId for the same application, the site commands use it when you leave out --env, as the other commands that take --env do. site deploy and site remove then act on that environment's own site. Add --app-site to act on the application's site instead.

site status shows what one environment serves, its own site, the application's or none, with the live deployment and the site URL. It takes --env, else the environment in multipaas.json, else the default environment, so check another environment with another run. It also says when MultiPaaS has disabled a site of the application, which stops every publish until it is enabled again.

multipaas site status --app APP_ID --env ENV_ID

To take one environment back to the application's site, remove the environment's own site:

multipaas site remove --app APP_ID --env ENV_ID

site remove for the application's site deletes it. Every environment without a live or disabled site of its own stops serving it, so the command needs --yes. --app-site picks the application's site whatever multipaas.json says; without multipaas.json, leaving out --env does the same:

multipaas site remove --app APP_ID --app-site --yes

Running the same site remove again after it succeeded succeeds too.

Single-page apps and the 404 page

SPA fallback is on unless you publish with --no-spa. With it on, a request for a path the site doesn't have serves the site's root index.html, so a single-page app's own routes work when someone opens or reloads one. With --no-spa, that request gets a 404 "file not found" page. Use --no-spa for a site made of separate pages. Each deployment keeps the choice it was published with, so pass the same flags every time you publish.

With SPA fallback on, the root index.html can be at most 4 MiB, because it answers every path the site doesn't have.

A path that ends in / serves the index.html in that folder: /about/ serves about/index.html. A path without the /, such as /about, is a path the site doesn't have, even when about/index.html exists. With SPA fallback it serves the root index.html, and with --no-spa it gets the 404 page. In a site of separate pages, link to /about/, or name the file, such as /about.html. A site URL where nothing is published answers 404 with a "No site here" page.

Limits

A deployment holds:

A file path must be valid UTF-8 and can't hold ", \ or a control character, and .multipaas/ is reserved for MultiPaaS.

site deploy checks the limits before it uploads anything. It refuses a directory over one with SITE_LIMIT_EXCEEDED, naming the limit and, for a file that's too large, its path. Leave out what the site doesn't serve, such as source maps, and shorten long paths. For the root index.html, make it smaller, or publish with --no-spa.

How long a publish takes

A new deployment reaches every location in about a minute. site deploy waits up to 3 minutes for the site URL to serve it. If the site URL doesn't serve it by then, the command exits 1 with SITE_NOT_LIVE_YET. The deployment is still published: run site status and open the site URL a little later.

MultiPaaS sets each file's Content-Type from its extension. Files ending in .html or .htm are served with Cache-Control: no-cache, so a browser checks for a newer version each time. Every other file is served with Cache-Control: public, max-age=300, so a browser that already loaded one can keep using it for up to 5 minutes. Most build tools put a hash of each asset's content in its name, which avoids this.

A new address can show "No site here" at first

After a publish to an address that had no site, such as a first publish, a new environment or a renamed label, visitors may see "No site here" for up to about a minute before the site appears. It ends without any action.

Renamed URL names redirect

Renaming a URL name changes the site URL. The old address keeps working: it redirects, with a 302, to the same path and query at the new address, as long as the new address serves a site.

An address built from two old names at once, such as an old environment name with an old application name, doesn't redirect.

Who can publish

Publishing or removing a site, an environment's own or the application's, needs environment.manage, counted as who can manage environments describes: only from a role granted in every environment. A CI deployer can't publish a site.

When a publish is refused

The CLI prints what to do next after each refusal. With --json, the code is one of these:

Use your own domain

MultiPaaS serves a site at its site URL only. To serve it at your own domain, such as www.example.com, put a CDN of your own in front of it, with the site URL's hostname as the CDN's origin. These steps use Amazon CloudFront, in your own AWS account.

  1. Request a certificate for your domain in AWS Certificate Manager, in the US East (N. Virginia) Region, us-east-1, which CloudFront requires. Validate it, with the DNS record ACM gives you or by email, and wait until its status is Issued: CloudFront can't use a certificate that is still pending validation.

  2. Create a CloudFront distribution:

    • Origin domain: your site URL's hostname, such as staging--shop--acme.multipaas.app, with the protocol HTTPS only.
    • Viewer protocol policy: Redirect HTTP to HTTPS, so visitors reach your domain over HTTPS only.
    • Cache policy: CachingOptimized. It follows the Cache-Control headers MultiPaaS sends.
    • Origin request policy: none. CloudFront then sends the origin's hostname as the Host header, which is the one MultiPaaS answers. A policy that forwards the viewer's Host, such as AllViewer, sends your domain instead, and MultiPaaS serves no site for it. If you need to forward other headers, use AllViewerExceptHostHeader.
    • Alternate domain name: your domain, with the certificate from step 1.
  3. Point your domain at the distribution, with a CNAME record for its *.cloudfront.net domain name, or an alias record in Route 53.

  4. If your site signs users in, add its callback URL on your domain to the environment's callback URLs, as Add end-user sign-in describes. set replaces the environment's callback URLs for that sign-in client, so repeat --redirect-uri for each one it should keep:

    multipaas envs redirect-uris set --app APP_ID --env ENV_ID --sign-in-client CLIENT_ID --redirect-uri https://www.example.com/callback
    

Publishing needs no change to the distribution: your domain serves a new deployment once the site URL does, apart from what the distribution has cached.

If you rename a URL name the site URL is built from, the old hostname redirects to the new one, and your distribution passes that redirect on to your visitors. It sends them to the site URL, not your domain, and without the query string, because CachingOptimized doesn't forward one to the origin. Change the distribution's origin to the new hostname as soon as you rename.

Another CDN works the same way when it sends the site URL's hostname as the Host header. In Cloudflare, for example, an Origin Rule can override the Host header. MultiPaaS tests fronting with CloudFront only.