title: Spring Cloud Gateway with Swagger 3 issue
body: <p>I've created a simple application with controller, exposed via Swagger3.
  It's working fine on its own, I can access and invoke via <code>http://localhost:8081/swagger-ui/index.html</code>.</p>
  <p>However if I add the Spring Cloud Gateway on top, I couldn't access Swagger, it has the banner but body is showing &quot;Failed to load remote configuration.&quot; .</p>
  <p>Upon inspection the log is showing</p>
  <pre class="lang-none prettyprint-override"><code>*&quot;GET http://localhost:8080/v3/api-docs/swagger-config 404 (Not Found)&quot;*
  *&quot;undefined /v3/api-docs/swagger-config&quot;*
  http://localhost:8080/api/servicea/swagger-ui/index.html
  </code></pre>
  <p>On a side note, the service could be invoked fine through gateway, i.e. <code>curl -X &quot;GET&quot; http://localhost:8080/api/servicea/test</code>.</p>
  <p>I believe I missed some configuration but I couldn't identify where.
  The simplified code is at <a href="https://github.com/sonic-air-swimmer/SpringCloudGatewaySwagger" rel="nofollow noreferrer">https://github.com/sonic-air-swimmer/SpringCloudGatewaySwagger</a></p>
  <p>Can someone please tell me what else should I configure?</p>
  <p><strong><strong>UPDATE</strong></strong>
  Finally able to identify the mistake, 2 configurations to make it works:</p>
  <ol>
  <li>Removing StripPrefix configuration on the Gateway</li>
  <li>Adding server.servlet.context-path on ServiceA</li>
  </ol>
  <p>It was caused by the StripPrefix hence when the ServiceA Swagger redirects it got error 404.</p>
  <p><strong><strong>UPDATE2</strong></strong>
  Although the previous way would work, it is not ideal as it's coupling the setting of services with the API Gateway. For example, if we decided to change the prefix for a particular service at API Gateway, the corresponding service's context path needs to be aligned as well.</p>
  <p>Therefore the correct way should be following the guide at <a href="https://springdoc.org/faq.html#how-can-i-deploy-springdoc-openapi-ui-behind-a-reverse-proxy" rel="nofollow noreferrer">https://springdoc.org/faq.html#how-can-i-deploy-springdoc-openapi-ui-behind-a-reverse-proxy</a></p>
  <p>Take note that it might appear to be not working because of the browser/springdoc cache. In that case just add springdoc.cache.disabled=true as per solution in <a href="https://github.com/springdoc/springdoc-openapi/issues/331" rel="nofollow noreferrer">https://github.com/springdoc/springdoc-openapi/issues/331</a></p>