NuxtN
Nuxt2w ago
Lars

Issues with ENV in production

I am currently experiencing issues with my docker production setup.



The nuxt config:
runtimeConfig: {
    public: {
      apiBase: process.env.NUXT_PUBLIC_API_URL || "http://localhost:8001",
      sanctum: {
          baseUrl: process.env.NUXT_PUBLIC_API_URL || "http://localhost:8002",
      },
    },
  },


Docker
frontend:
    image: IMAGE
    container_name: smartlab-frontend
    restart: always
    environment:
      - NUXT_PUBLIC_API_URL=DOMAIN
    ports:
      - "3002:3000"
    depends_on:
      - api
    networks:
      - smartlab-net



FROM node:24-alpine AS prod
WORKDIR /app

# Copy built output and package files
COPY --from=build /app/.output ./.output
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/package-lock.json ./package-lock.json

# Install only production dependencies
RUN npm ci --omit=dev

# Expose Nuxt production port
EXPOSE 3000

# Start Nuxt 4 production server
CMD ["node", ".output/server/index.mjs"]


This doesnt work can anyone help me with how i should set up the enviroment variables in a production?
Was this page helpful?