Skip to content

Fallthrough proxy with Swagger-UI #3738

@abjugard

Description

@abjugard

I am using the latest version of the following dependencies:

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>3.4.3</version>
	<relativePath/>
</parent>
[...]
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
	<groupId>org.springdoc</groupId>
	<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
	<version>2.8.5</version>
</dependency>

And the following configuration in application.yml

spring:
  cloud:
    gateway:
      routes:
        - id: legacy_proxy
          uri: http://localhost:8000
          predicates:
            - Path=/**
          filters:
            - RewritePath=/(?<segment>.*), /legacy-app-1/${segment}
          order: 1000

I have a controller:

@RestController
@RequestMapping("/example")
public class ExampleController {
    @GetMapping()
    public String getString() {
        return "test";
    }
}

When this application is running I can make requests to /example which hits the controller endpoint, and I can make requests to /some/other/path which proxies the request correctly to http://localhost:8000/legacy-app-1/some/other/path, but in this configuration I can not access /swagger-ui/index.html. Curiously not all Swagger endpoints are affected, I can access /v3/api-docs.

If I change to Path=/legacy/** then Swagger UI works correctly.

Any idea why the /swagger-ui/index.html path is affected like this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions