I have a Mongo, Express, React Node app that is currently deployed in a microk8s pod. I am trying to setup Ingress for the app. The express server is setup to serve the react with express.static like below
app.use(express.static('DemoApp/build'));
app.get('*', function(req, res, next) {
res.sendFile(path.resolve(__dirname, 'DemoApp', 'build', 'index.html'));
});
Everything works fine when I navigate to the ip:port of the kubernetes cluster and even everything works fine when I navigate to the FQDN for the ingress host but as soon as I add a path to the ingress then the app only shows a white screen. One note, my kubernetes node and workstations are all running inside an internal private network. I am not trying to expose anything outside of that. I have tried to follow the step provided in this post (ReactJS app displays whitescreen using Kubernetes Ingress) but it has not fixed the issue. I have the built in ingress controller enabled for microk8s.
Below is the YAML I am using for ingress that doesnt work
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: demo-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
namespace: default
spec:
rules:
- host: apps.sst.com
http:
paths:
- path: /demo(/|$)(.*)
backend:
serviceName: mern-demo
servicePort: 4000
Here is the YAML for ingress that does work
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: demo-ingress
annotations:
namespace: default
spec:
rules:
- host: apps.sst.com
http:
paths:
- path:
backend:
serviceName: mern-demo
servicePort: 4000
One other note is that my app is using react router. Based on further research I am wondering if this affects things at all.
Any help would be greatly appreciated. Thanks