Deploy the Websites
Upload the websites to Firebase Hosting (free SSL, recommended) or to your own server or cPanel host.
Pick one way. Both work for all four websites, and you can mix them (for example the landing page on your usual host, the panels on Firebase).
Fast, free SSL, and in the same Firebase project. One Firebase project can hold several sites, one per website.
1. Install the CLI and sign in (once):
npm install -g firebase-tools
firebase login
2. Create the extra sites. The project already has one site named after the project ID. Create one more per website. Site names are unique across all of Firebase, so add your own word:
firebase hosting:sites:create yourbrand-admin --project your-project-id
firebase hosting:sites:create yourbrand-restaurant --project your-project-id
firebase hosting:sites:create yourbrand-order --project your-project-id
Use the default site (your-project-id) for the landing page, or create a fourth site for it.
3. Add a hosting block to each project's firebase.json. admin_panel, customer_web and restaurant_web already have a firebase.json written by FlutterFire. Keep the "flutter" part and add "hosting" next to it:
{
"flutter": { ...keep what is here... },
"hosting": {
"site": "yourbrand-admin",
"public": "build/web",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [{ "source": "**", "destination": "/index.html" }]
}
}
Same in restaurant_web/firebase.json ("site": "yourbrand-restaurant") and customer_web/firebase.json ("site": "yourbrand-order"). For the landing page, create landing_page/firebase.json. It is a plain site, so no rewrite:
{
"hosting": {
"site": "your-project-id",
"public": ".",
"ignore": ["firebase.json", "README.md", "**/.*"]
}
}
4. Choose the project in each folder. admin_panel already has a .firebaserc: run this there too so it points to your project, not the demo one:
firebase use --add
Pick your project and give it the alias default.
5. Build and deploy, in each Flutter web folder:
flutter build web --release
firebase deploy --only hosting
In landing_page just run firebase deploy --only hosting.
✔ hosting[yourbrand-admin]: release complete
✔ Deploy complete!
Hosting URL: https://yourbrand-admin.web.app
Open the Hosting URL. It works at once with HTTPS. To update a site later, build and deploy again in that folder.
Do not run firebase deploy without --only hosting
In a folder that also lists Firestore or Functions, a plain firebase deploy would deploy those too. The rules and functions are deployed by the setup tool; keep --only hosting here.
1. Build each Flutter web project (Prepare & build). The landing page needs no build.
2. Upload. Give each website its own domain or subdomain. Delete the old files first, then upload everything inside build/web/ (not the folder itself) to that site's document root, with FTP, the cPanel File Manager or SSH. For the landing page, upload the contents of landing_page/.
3. Add the page rule so addresses like /orders open after a refresh instead of a 404.
Apache or cPanel: put this .htaccess in the site's root, next to index.html. Tip: save it as web/.htaccess in the project; flutter build web copies it into build/web every time.
RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Send every page address to index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.html [L]
If your FTP program hides dot-files, turn on "show hidden files" so it is uploaded. The landing page needs no .htaccess.
Nginx: inside the site's server { } block:
root /var/www/yourbrand-admin; # the uploaded build/web files
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
4. Clear the cache after every upload. If your host has a CDN or cache (Cloudflare, LiteSpeed…), purge it, then open the site with CtrlShiftR.
Hosting in a sub-folder
A subdomain is easiest. For yourdomain.com/admin/, change <base href="/"> in web/index.html to <base href="/admin/">, rebuild, and point the rewrite rule to /admin/index.html. The push service worker is registered at /firebase-messaging-sw.js, so browser notifications only work when the site is at the root of its domain.
Next
Connect your own domains and turn on HTTPS: Domains & SSL.