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:
- at most 2,000 files;
- at most 100 MiB in all;
- at most 25 MiB in any one file;
- at most 320 KiB of file paths in all, counted in UTF-8 bytes, because one answer carries every file's upload link;
- with SPA fallback on, at most 4 MiB in the root
index.html.
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 old application or environment URL name redirects until another application, or another environment of the same application, takes the name.
- An old client URL name redirects for 30 days after the rename.
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:
SITE_LIMIT_EXCEEDED: the directory is over a limit. See Limits.SITE_DIR_INVALID: the directory doesn't exist, isn't a directory or holds no files, or a link under it can't be followed or leads outside it.SITE_PATH_INVALID: a site can't hold a file at the path it names..multipaas/is reserved, and a path must be valid UTF-8 and can't be too long or hold",\or a control character. Rename or remove the file.UPLOAD_REFUSED: an upload failed, after three more tries when the storage service was at fault. Nothing was published. Runsite deployagain. Each upload link expires 15 minutes aftersite deployasks for it, and the message says "refused" when the storage service turned an upload away for that, or "stopped" when the 15 minutes ran out during the upload and the CLI ended it.SITE_UPLOAD_INCOMPLETE: some files weren't uploaded, or changed aftersite deployread them;missingandmismatchedlist them. Nothing was published. Runsite deployagain once the directory stops changing.SITE_DEPLOYMENT_NOT_PUBLISHABLE: another publish replaced the deployment before it was published, or it waited too long. Runsite deployagain, which makes a new one.SITE_ROUTES_PENDING: the change is saved, but the site URL doesn't reflect it yet.site deployasks three more times first. What to do next depends on the command:- from
site deploy: the deployment is published, and the daily reconcile writes its routes.site statusshows what an environment serves. Runningsite deployagain publishes the directory as a new deployment, which replaces whatever is live by then. - from
site remove: the site is removed. Run the samesite removeagain, or wait for the daily reconcile to repair it. - from
url-name rename: the name is changed. Run the same rename again, with the same name, to finish. - from
envs deleteorenvs remove: the environment is deleted. Run the same command again. ANOT_FOUNDthen means the environment is gone; its site address stops serving at the application's next site change or the daily reconcile. - from
envs create: the environment is created. Don't create it again, which is refused because the name is taken. Its site URL catches up the next time you publish or remove a site of the application or rename a URL name, or the daily reconcile.
- from
INTERNAL_SERVER_ERROR: something failed on the server. When the publish step answers it,site deployasks three more times before it reports it. If its message says the deployment is published,site statusshows what an environment serves. Otherwise runsite deployagain, which publishes the directory as a new deployment that replaces whatever is live by then. Runsite statusorsite removeagain if either answered it; removing a site that is already gone succeeds.SITE_NOT_LIVE_YET: the deployment is published, but the site URL didn't serve it within 3 minutes. Runsite statusin a few minutes to see what an environment serves. Runningsite deployagain publishes the directory as a new deployment, which replaces whatever is live by then.SITE_DISABLED: MultiPaaS has disabled a site of this application. None of the application's sites can be published or removed until MultiPaaS enables it again. Send feedback to ask why. Whensite deployanswers it after publishing, its message names the deployment: it is published, but no environment serves it.CLI_ERROR: besides a failure on your side, such as no network,site deployanswers it after publishing when no environment serves the published site, for example because the application's site was deleted meanwhile, or the environment whose site it published no longer serves it. Its message names the deployment.site status --env ENV_IDshows what an environment serves.NOT_FOUND: the application isn't one you can reach, the environment isn't one of the application's or is being removed, orsite removefound no site to remove there. Check the ids withmultipaas apps listandmultipaas envs list --app APP_ID.UNAUTHORIZED: fromsite deployorsite remove, you don't have the permission Who can publish names, or you act as a CI deployer, which can do neither. Signed in as yourself, anysitecommand also answers it when your access to the application is removed, or the application is deleted, while the command runs. Check--appagainstmultipaas apps list.CONFIRMATION_REQUIRED: deleting the application's site needs--yes, because every environment without a live or disabled site of its own stops serving it. To remove one environment's own site instead, add--env.
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.
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.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-Controlheaders MultiPaaS sends. - Origin request policy: none. CloudFront then sends the origin's hostname as the
Hostheader, which is the one MultiPaaS answers. A policy that forwards the viewer'sHost, 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.
- Origin domain: your site URL's hostname, such as
Point your domain at the distribution, with a CNAME record for its
*.cloudfront.netdomain name, or an alias record in Route 53.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.
setreplaces the environment's callback URLs for that sign-in client, so repeat--redirect-urifor 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.