Skip to content

CORS problems since 5.0.0 on management and config endpoints #371

@pdelaby

Description

@pdelaby
Overview of the issue

Since v5.0.0, the registry served behind a traefik proxy (or letsencrypt) on docker seems to have CORS issues on post methods ( authenticate, config/encrypt, management/loggers).

Sample configuration

jhipster-registry:
       image: jhipster/jhipster-registry:v5.0.2
       volumes:
           - jhipster-registry-data:/root/.ssh
       environment:
           - _JAVA_OPTIONS=-Xmx512m -Xms256m
           - SPRING_PROFILES_ACTIVE=prod
           ...
           - LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_WEB_CORS=TRACE
           - JHIPSTER_CORS_ALLOWED-ORIGINS=https://my.domain.name
           - 'JHIPSTER_CORS_ALLOWED-METHODS=GET, PUT, POST, DELETE, OPTIONS'
           - 'JHIPSTER_CORS_ALLOWED-HEADERS="*"'
           - 'JHIPSTER_CORS_EXPOSED-HEADERS='
           - 'JHIPSTER_CORS_ALLOW-CREDENTIALS=true'
       networks:
          - "traefik-public"
       deploy:
          replicas: 1
          labels:
           - traefik.frontend.rule=Host:my.domain.name
           - traefik.enable=true
           - traefik.port=8761
           - traefik.tags=traefik-public
           - traefik.docker.network=traefik-public
           # Traefik service that listens to HTTP
           - traefik.redirectorservice.frontend.entryPoints=http
           - traefik.redirectorservice.frontend.redirect.entryPoint=https
           # Traefik service that listens to HTTPS
           - traefik.webservice.frontend.entryPoints=https
       depends_on:
          - traefik

The configuration worked in previous versions, but a http 403 'invalid cors request' is now returned.

I added

- JHIPSTER_CORS_ALLOWED-ORIGINS=https://my.domain.name
- 'JHIPSTER_CORS_ALLOWED-METHODS=GET, PUT, POST, DELETE, OPTIONS'
- 'JHIPSTER_CORS_ALLOWED-HEADERS="*"'
- 'JHIPSTER_CORS_EXPOSED-HEADERS='
- 'JHIPSTER_CORS_ALLOW-CREDENTIALS=true'

in the docker-compose, and it fixed the problem for /authenticate, but other POST on endpoints (like the encryption in configuration/encryption or changing the log levels) doesn't seems to share that configuration (they use the CORS configuration mapped to '/**' ).

Am I missing a property ?

Motivation for or Use Case

It worked in previous version ( before 5.0.0).

Reproduce the error

Start jhipster-registry on docker, served behind an https domain name.

JHipster Registry Version(s)

5.0.2

  • Checking this box is mandatory (this is just to show you read everything)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions