We are trying to host our frontend and our backend on the same domain.
Nuxt will be https://ourdomain.com/
Strapi will be https://ourdomain.com/api
Strapi admin panel will be https://ourdomain.com/api/admin
Currently Nuxt and Strapi API are working fine with
/api/leads returning data from the database
When I try and go to /api/admin in order to access the admin panel I am greeted with a Not Found
However when I go to /api/api/admin it “works” (the html is loaded but the js is still trying to be loaded from /api/admin)
/api/api/admin
/api/admin
/api
/api/leads
As you can see the API is working but the admin panel seems to be confused
Server.js (host and port are 0.0.0.0 and 1337)
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
url: env('STRAPI_URL', '/api'),
port: env.int('PORT', 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'omitted'),
},
},
});
Our Docker File
FROM node:14-alpine
ENV NODE_ENV production
WORKDIR /app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install --only=production
ENV STRAPI_URL '/api'
COPY . .
RUN npm run build
EXPOSE 1337
HEALTHCHECK --interval=30s --timeout=300s --retries=5 --start-period=30s CMD curl --fail http://localhost:1337/home || exit 1
CMD ["npm", "run", "start"]
Strapi Startup Logs
Ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: strapi-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
tls:
- hosts:
- ourdomain.dev
secretName: cloudflare-origin-cert
rules:
- host: ourdomain.dev
http:
paths:
- path: /api(/|$)(.*)
pathType: Prefix
backend:
service:
name: strapi-service
port:
number: 80
- path: /()(.*)
pathType: Prefix
backend:
service:
name: nuxt-service
port:
number: 80