1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Multiple SPA application in subdirectories + SPA in root directory

Discussão em 'Angular' iniciado por Damian Martyniuk, Outubro 20, 2024.

  1. I cant figure out how to have this structure of locations working for my app

    / <- base location serves angular "base" app

    /cms/en <- multiple language directories serve localized angular "cms" app

    /cms/nl

    /cms/de ... etc

    and my config kinda works, but only until i open base app... it's like my application "hijacks" routing, never hits nginx locations and just serves 404 for page.com/cms/nl. Before loading page.com in browser, my page.com/cms/nl location works as it should Base app has wildcard route for not matched urls.

    it's some cacheing issue, i tried so many thing i'am totally lost now

    how would i fix it ?

    my server block looks like this

    server{
    server_name page.com;
    root /var/www/page.com;

    location /cms/fr {
    alias /var/www/html/page.com/cms/fr;
    try_files $uri $uri/ @cmspl;

    # kill cache
    add_header Last-Modified $date_gmt;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
    if_modified_since off;
    expires off;
    etag off;
    }

    location /cms/en {
    alias /var/www/html/page.com/cms/en;
    try_files $uri $uri/ @cmsen;
    }

    location /cms/nl {
    alias /var/www/html/page.com/cms/nl;
    try_files $uri $uri/ @cmsnl;
    }

    location @cmspl {
    rewrite /cms/fr/(.*)$ /cms/fr/index.html?/$1 last;
    }

    location @cmsen {
    rewrite /cms/en/(.*)$ /cms/en/index.html?/$1 last;
    }

    location @cmsnl {
    rewrite /cms/nl/(.*)$ /cms/nl/index.html?/$1 last;
    }

    location / {
    #add_header content-type text/plain;
    #return 200 'location base';
    proxy_pass http://127.0.0.1:4811;
    proxy_set_header Host $host;

    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;

    proxy_no_cache 1;
    # even if cached, don't try to use it
    proxy_cache_bypass 1;

    add_header Last-Modified $date_gmt;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
    if_modified_since off;
    expires off;
    etag off;
    }
    }

    Continue reading...

Compartilhe esta Página