Contents
Angular is a front-end framework. After the build, all that remains of it on the server is static files, which is why it runs on the simplest hosting. Two cases need more than that: server-side rendering, and the API the app gets its data from.
What are you actually hosting?
| Part | What it is | Where it runs |
|---|---|---|
| Angular app (SPA) | Static files after ng build |
Any plan |
| Angular with SSR | A Node.js server that renders the pages | AI and developer plans |
| The API | A separate project: PHP, Laravel, Node.js or Python | PHP on any plan, the rest on the AI and developer plans |
Deploying as a single-page app
- On your computer:
npm ci, thenng build. - The output is in
dist/project-name/browser/. Upload the contents of that folder, not the folder itself, topublic_htmlwith the file manager in cPanel. - Create an
.htaccessfile next toindex.html:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
- Open an inner link directly, and refresh the page.
Without the rule you get a 404 on page refresh. If you see a blank page, open the developer tools and look at the files that failed to load, as in blank page after deploy.
The API address
The API address is written in the environment files under src/environments/ and baked into the code at build time. Make sure the production build points at the real domain, not at localhost. Any value in those files reaches the browser, so never put a secret key there.
If the API is on another subdomain, set CORS headers on it. If it is on the same domain under a path such as /api, you do not need them.
Angular with SSR
If you added @angular/ssr, the build produces two folders: browser/ for static files, and server/ with a Node.js server:
- Build on your computer and upload the
dist/folder withpackage.jsonto a folder outsidepublic_html. - Add a startup file
app.cjscontaining:import("./dist/project-name/server/server.mjs"); - Create the app from Setup Node.js App in cPanel with Node.js 24, then click Run NPM Install and Restart.
The generated server listens on process.env.PORT, which is what Passenger sets. Details are on the Node.js hosting page.
Limits to know
- The build needs memory, so build on your computer or in GitHub Actions.
- No SSH on the ordinary plans. Upload with the file manager or Git in cPanel.
- Outgoing connections from the server are HTTPS only, which concerns the API and SSR, not the static app.
- No Docker and no root.
On ArabyHost
A static Angular app runs on every plan, served by LiteSpeed with a free automatic SSL certificate and daily backups. An API in PHP or Laravel runs on the same plans, and one in Node.js or Python on the AI and developer plans with SSH and Git. If the API is written with NestJS, see NestJS hosting.
Prices are shown in your currency on the pricing page, and the renewal price is the price you signed up at. For other frameworks: React and Vue.
FAQ
Does Angular need Node.js on the hosting?
Not in the usual case. Node.js is needed on your computer for the build only, and the output is HTML, JavaScript and CSS files any web server can serve. It is needed on the server if you turn on SSR.
Why do inner links return 404 when I refresh the page?
Because Angular's routing happens in the browser, and the server finds no file at that path. The fix is a rule in .htaccess that sends every path that does not exist to index.html.
Where do I upload the app if I want it in a subfolder?
Build it with the base path set, for example ng build --base-href /app/, then upload the files to that folder and change the rewrite rule to point at the index.html inside it.