Skip to content
By stack3 min read

Angular hosting: a single-page app, or SSR on Node.js

Short answer

An ordinary Angular app is a single-page app: ng build produces static files in the dist folder that you upload to public_html on any plan, with a rule in .htaccess that sends routes back to index.html. If you add server-side rendering (SSR), the output includes a Node.js server that runs on the AI and developer plans. The API the app talks to is a separate project, hosted according to its language.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. What are you actually hosting?
  2. Deploying as a single-page app
  3. The API address
  4. Angular with SSR
  5. Limits to know
  6. On ArabyHost

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

  1. On your computer: npm ci, then ng build.
  2. The output is in dist/project-name/browser/. Upload the contents of that folder, not the folder itself, to public_html with the file manager in cPanel.
  3. Create an .htaccess file next to index.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>
  1. 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:

  1. Build on your computer and upload the dist/ folder with package.json to a folder outside public_html.
  2. Add a startup file app.cjs containing: import("./dist/project-name/server/server.mjs");
  3. 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.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.