When deploying my Angular application to production I'm having an issue where my application can't see/use the bundled scripts generated on build (runtime, main, css, etc.)
Background:
I have a URL that two Angular apps are supposed to run off of.
- example.com
- example.com/subroute
Application #1 works great and as expected.
Application #2 seems to find the correct index.html file when I go to the URL, but it cannot find any of the created scripts (https://example.com/subroute/runtime-es2015.ad3f6d66c5c633672c3c.js).
Any ideas on what else I can try here? Thank you in advance!
UPDATE #1:
If I change the kubernetes ingress config to the following, I am able to get to my app, but now just can't hit the expected /subroute/api route.
For example, I can hit https://example.com/subroute and my app loads as intended, but if I do a GET request to https://example.com/subroute/api/entity, I get a 404.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/proxy-read-timeout: "12h"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: team-webapp-public-ingress
namespace: default
spec:
tls:
- hosts:
- example.com
secretName: example-tls
rules:
- host: example.com
http:
paths:
- path: /subroute(/($|.*))?
backend:
serviceName: example-subroute-frontend-service
servicePort: 80
- host: example.com
http:
paths:
- path: /subroute/api/
backend:
serviceName: API-service
servicePort: 9872
App #2 Angular Config
npm run build -- --output-path=./dist/out --configuration production --buildOptimizer=true --base-href '/subroute/' --deployUrl '/subroute/'
App #2 Nginx Config
# Expires map
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/json max;
application/javascript max;
~image/ max;
}
server {
default_type text/html;
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
expires $expires;
gzip on;
}
App #2 Kubernetes Config
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/proxy-read-timeout: "12h"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /$1
name: team-webapp-public-ingress
namespace: default
spec:
tls:
- hosts:
- example.com
secretName: example-tls
rules:
- host: example.com
http:
paths:
- path: /subroute/
backend:
serviceName: example-subroute-frontend-service
servicePort: 80
- host: example.com
http:
paths:
- path: /subroute/api/
backend:
serviceName: API-service
servicePort: 9872