79093619

Date: 2024-10-16 10:30:16
Score: 0.5
Natty:
Report link

I found the resolution, In Angular 18 dist/browser folder contains index.csr.html instead of index.html, so we have to conf file Nginx accordingly.

Below is the updated code for home-app.conf

server {
    listen 80;
    server_name localhost;

    # Serve static files for CSR
    location / {
        root /var/www/dist/home-app/browser;
        index index.csr.html;  # Set index.csr.html as the default index file
        try_files $uri $uri/ /index.csr.html;  # Fallback to index.csr.html for CSR
    }

    # Serve dynamic SSR content for specific routes
    location /ssr {
        proxy_pass http://localhost:4000;  # Forward requests to your Node.js SSR server
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: user2279515