#Hard refresh on dockerized angular application

5 messages · Page 1 of 1 (latest)

oblique wharf
#

I am having an issue making hard refresh work on my dockerized angular app
I am using caddy
With this setup, im getting "This localhost page can’t be foundNo webpage was found for the web address: https://localhost/
HTTP ERROR 404"

However if i remove the handle part and replace it with "reverse_proxy angular:80", it works fine but the issue remains on hard refresh

Angular docker file:

# Use the official Node.js image to build the Angular app
FROM node:18-alpine AS build

WORKDIR /app

COPY package.json package-lock.json ./

RUN npm install

COPY . .

RUN npm run build --prod

# Use a lightweight web server to serve the Angular app
FROM nginx:alpine

# Copy the Angular app build output to the Nginx html directory
COPY --from=build /app/dist/app /usr/share/nginx/html

# Expose the port that the container will run on
EXPOSE 80

Caddy File:

{
  email [email protected]
}

https://localhost, https://domain.com {
  reverse_proxy /api/* api:5000

  # Handle requests for the Angular app
  handle {
    # Serve static files from Angular build directory
    root * /usr/share/nginx/html
    file_server

    # Handle routing for SPA
    try_files {path} /index.html
  }
}

oblique wharf
#

also i have docker compose:

services:
  api:
    build:
      context: ./app/Code/App  # Directory containing the Dockerfile and context for the build
      dockerfile: Dockerfile  # Specify the custom Dockerfile name here
    image: ${api_image}
    container_name: api
    environment:
      ConnectionStrings__DefaultConnection: Host=db;Database=AppDbContext;Username=postgres;Password=admin
    ports:
      - "5000:5000"
      #- "5001:5001"
    networks:
      - app-network
    depends_on:
      - db


  angular:
    build:
      context: ./app-client/code/app  # Directory containing the Dockerfile and context for the build
      dockerfile: Dockerfile
    image: ${angular_image}
    container_name: angular
    networks:
      - app-network


  db:  # Define the 'db' service
    image: postgres:15  # Use the PostgreSQL 15 image from Docker Hub
    container_name: postgres-db  # Name to assign to the container
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: admin
      POSTGRES_DB: AppDbContext
    ports:
      - "5432:5432"
    networks:
      - app-network
      

  caddy:
    image: caddy:latest
    container_name: caddy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  caddy_data:
  caddy_config:
  pgdata:
scenic mulch
#

Hello folk

#

Did you alreary configure a redirect file?