Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the basePath using the request context path if present #3158

Merged
merged 2 commits into from Jan 6, 2020

Conversation

jgcollings
Copy link
Contributor

This allows the X-Forwarded-Prefix header to work correctly

fix for issue #3157

Test with the following steps:
1 - build and install into local maven repo.
2 - clone repo https://github.com/jgcollings/webfluxtest.git
3 - run the project: mvn spring-boot:run
4 - use the following curl command to get the api spec:

curl -X GET
http://localhost:8080/v2/api-docs
-H 'X-Forwarded-Host: www.acme.com'
-H 'X-Forwarded-Port: 80'
-H 'X-Forwarded-Prefix: /myprefix'
-H 'X-Forwarded-Protocol: http'

Notice that the basePath in the spec is "/myprefix"

This allows the X-Forwarded-Prefix header to work correctly
@codecov
Copy link

codecov bot commented Oct 23, 2019

Codecov Report

Merging #3158 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3158      +/-   ##
============================================
+ Coverage     92.91%   92.93%   +0.02%     
- Complexity     3512     3514       +2     
============================================
  Files           382      382              
  Lines          9330     9330              
  Branches        768      769       +1     
============================================
+ Hits           8669     8671       +2     
+ Misses          472      471       -1     
+ Partials        189      188       -1
Impacted Files Coverage Δ Complexity Δ
...tation/swagger2/web/Swagger2ControllerWebFlux.java 81.25% <100%> (ø) 5 <0> (+1) ⬆️
...umentation/spring/web/scanners/ApiModelReader.java 95.46% <0%> (+0.56%) 88% <0%> (+1%) ⬆️

@M3yo
Copy link

M3yo commented Nov 28, 2019

Hi everyone,

When this fix will be merged ?

Both controllers (webMvc and WebFlux) does not work the same regarding basePath, the X-Forwarded-Prefix is ignored in Webflux mode which make the "Try it out" feature unusable when using a reverse proxy. :(

@jgcollings
Copy link
Contributor Author

I would like this merged soon as well. It has been a problem for us for quite a while and I have to tell developers constantly that the try it out button does not work.

@dilipkrish dilipkrish added the PR label Jan 6, 2020
@dilipkrish dilipkrish added this to the 3.0 milestone Jan 6, 2020
Copy link
Member

@dilipkrish dilipkrish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jgcollings!

@dilipkrish dilipkrish merged commit 650ef94 into springfox:master Jan 6, 2020
@jgcollings jgcollings deleted the jgcollings/basepath branch January 7, 2020 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants