3

I have a SPA and serving it from Nginx which works fine. I also have an simple index.html inside a sub-folder.

Spa links to index.html for displaying a sub application which is simple html with it's own css/js. When trying to browse the subfolder app, nginx redirects to the base spa.

nginx config

 location / {              
                try_files $uri $uri/ /index.html =404;
        }

location /3d-viewer/ {
                 try_files $uri $uri/ /3d-viewer/index.html;
        }

Thanks for help.

Chirdeep Tomar
  • 4,281
  • 8
  • 37
  • 66

1 Answers1

0

in angular app config https://angular.io/api/common/APP_BASE_HREF

import {Component, NgModule} from '@angular/core';
import {APP_BASE_HREF} from '@angular/common';

@NgModule({
  providers: [{provide: APP_BASE_HREF, useValue: '/3d-viewer'}]
})
class AppModule {}

nginx.conf

location /3d-viewer {
  alias /var/www/html/3d-viewer;
  try_files $uri $uri/ /index.html =404;
  expires 0;
  add_header Cache-Control no-cache;
  add_header X-Cache-Status REVALIDATED;
  break;
}
Ramil Gilfanov
  • 552
  • 1
  • 8
  • 12