Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
NextJS Docker Container in K8s Throwing Uncaught SyntaxError: Unexpected token '<'

Creating a default NextJS typescript app with npx create-next-app@latest --ts .

 "next": "12.1.6",
 "react": "18.1.0",
 "react-dom": "18.1.0"

and then a simple Dockerfile deployed to kubernetes minikube and then minikube tunnel to access the port

FROM node:alpine

WORKDIR /app
COPY package.json .
RUN yarn install
COPY . .


CMD ["yarn", "dev"]

Shows a blank page with the following errors in the console when running in browser

Uncaught SyntaxError: Unexpected token '<'

However running the same image via docker run, in non k8s, works fine. I have had a look at the HTML for absolute paths as suggested in other threads and see that the path points to

http://myhost.com/_next/static/chunks/react-refresh.js?ts=1654439747173

When hovering over src

<div id="__next">
<script src="/_next/static/chunks/react-refresh.js?ts=1654439747173"></script>

deployment.yaml and ingress files

apiVersion: apps/v1
kind: Deployment
metadata:
 name: front-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: front
  template:
    metadata:
      labels:
        app: front
    spec:
      containers:
        - name: front
          imagePullPolicy: Never
          image: mine/front:latest
          resources:
           limits:
            memory: 512Mi
            cpu: "1"
---
apiVersion: v1
kind: Service
metadata:
  name: front-service
spec:
  selector:
    app: front
  ports:
    - name: front
      protocol: TCP
      port: 3000
      targetPort: 3000


// ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    - host: myhost.com
      http:
        paths:
          - path: /?(.*)
            pathType: Prefix
            backend:
              service:
                name: front-service
                port:
                  number: 3000

Any idea on getting it running in kubernetes?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I got it working by updating the ingress rewrite target

changing

nginx.ingress.kubernetes.io/rewrite-target: /$2

to

nginx.ingress.kubernetes.io/rewrite-target: /$1

and the path to

path: /(.*)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda