使用域名訪問swagger 一直提示Unable to infer base url.

1. 錯誤提示

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 http://example.org/api/v2/api... then the base url is http://example.org/api/. Please enter the location manually:html

2. 狀況說明

  1. 使用IP訪問localhost:8080/api/swagger-ui.html 沒有問題
  2. 使用nginx映射之後,訪問https://www.xxxxx.com/api/swa... 開始出現問題

3. 百度過程遇到的坑

  1. 解決辦法:在啓動類上加上註解@EnableSwagger2
  2. 被攔截nginx

    /swagger-ui.html
    /webjars/**
    /v2/**
    /swagger-resources/**

4. 問題排除過程

  1. 增長EnableSwagger2
  2. 項目當中沒有使用攔截
  3. 在頁面使用F12查看報錯web

    1. image
  4. 查看此ERR_CONTENT_LENGTH_MISMATCH說明api

    1. 發現貌似是nginx問題
  5. 查看nginx錯誤日誌
  6. 發現proxy_temp目錄沒有權限
  7. 偷懶賦予777權限

5. 有幫助的鏈接

https://blog.csdn.net/mr_ooo/...ui

相關文章
相關標籤/搜索