title: Springfox swagger-ui.html unable to infer base URL - Caused by missing cookies
body: <p>We have our Spring Boot services behind an API Gateway. With an earlier version of Springfox - 2.1.2 we had no issues in loading the <code>swagger-ui.html</code> page. This worked with Spring Boot 1.4.3.RELEASE. From then, we have upgraded to Boot 1.5.7 and upgraded Springfox to 2.8.0.</p>
  
  <p>Now if we load the page we get an alert box with the following long message.</p>
  
  <blockquote>
    <p>Unable to infer base url. This is common when using dynamic servlet
    registration or when the API is behind an API Gateway. The base url is
    the root of where all the swagger resources are served. For e.g. if
    the api is available at <a href="http://example.org/api/v2/api-docs" rel="noreferrer">http://example.org/api/v2/api-docs</a> then the
    base url is <a href="http://example.org/api/" rel="noreferrer">http://example.org/api/</a>. Please enter the location
    manually</p>
  </blockquote>
  
  <p>I got some hints searching online, but it does not seem those situations apply to us. For one, if I simply revert back the versions, it starts working again through the same API Gateway.</p>
  
  <p>Tracking the traffic, it seems calls to three XHR resources made by the .html page is causing issues. These are returning 401 from our API gateway. And the reason they return 401 is because the cookies are not passed along.</p>
  
  <p>The three calls are:</p>
  
  <ul>
  <li><a href="https://base_address/base_context/swagger-resources/configuration/ui" rel="noreferrer">https://base_address/base_context/swagger-resources/configuration/ui</a></li>
  <li><a href="https://base_address/base_context/swagger-resources/configuration/security" rel="noreferrer">https://base_address/base_context/swagger-resources/configuration/security</a></li>
  <li><a href="https://base_address/base_context/swagger-resources" rel="noreferrer">https://base_address/base_context/swagger-resources</a></li>
  </ul>
  
  <p>If I load these URLs as pure browser requests - they work - because cookies are sent.</p>
  
  <p>I doubt if CORS applies since the HTML is being served from the same address as the swagger JSON and actual service calls. </p>
  
  <p>Any idea why this may be happening? Anybody faced similar issues? Suggestions for workaround? Thanks much in advance.</p>