Swagger absolute paths make API not working when serving on subpath #2318

Closed
opened 2025-11-02 04:32:42 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @OndrejSpanel on GitHub (Sep 11, 2018).

  • Gitea version (or commit ref): 1.5.1
  • Git version: 1.9.1
  • Operating system: Debian 7
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

I am serving my gitea on URL like https://www.myserver.net/gitea, configured using Apache reverse proxy mapping this URL to http://localhost:3000. Main reason for this is my current SSL certificate does not allow subdomains. Everything works fine, the only problem I have is with Swagger.

As Swagger API URLs start with /, they override the /gitea part of the base part, forming URLs like https://www.myserver.net/api/v1/ instead of https://www.myserver.net/gitea/api/v1/.

The APIs themselves work fine in the form https://www.myserver.net/gitea/api/v1/version, it is only the Swagger demo which does not.

Screenshots

image

image

Originally created by @OndrejSpanel on GitHub (Sep 11, 2018). - Gitea version (or commit ref): 1.5.1 - Git version: 1.9.1 - Operating system: Debian 7 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [x] Not relevant - Log gist: ## Description I am serving my gitea on URL like https://www.myserver.net/gitea, configured using Apache reverse proxy mapping this URL to http://localhost:3000. Main reason for this is my current SSL certificate does not allow subdomains. Everything works fine, the only problem I have is with Swagger. As Swagger API URLs start with /, they override the /gitea part of the base part, forming URLs like https://www.myserver.net/api/v1/ instead of https://www.myserver.net/gitea/api/v1/. The APIs themselves work fine in the form https://www.myserver.net/gitea/api/v1/version, it is only the Swagger demo which does not. ## Screenshots ![image](https://user-images.githubusercontent.com/6927223/45349721-59312800-b5b2-11e8-8b3b-4bde59b979c5.png) ![image](https://user-images.githubusercontent.com/6927223/45349473-a791f700-b5b1-11e8-81c3-216f206b6571.png)
GiteaMirror added the issue/duplicate label 2025-11-02 04:32:42 -06:00
Author
Owner

@techknowlogick commented on GitHub (Sep 11, 2018):

This may be resolved in version 1.6.0-dev of Gitea which uses templating for swagger which will use subpaths.

@techknowlogick commented on GitHub (Sep 11, 2018): This may be resolved in version 1.6.0-dev of Gitea which uses templating for swagger which will use subpaths.
Author
Owner

@lafriks commented on GitHub (Sep 12, 2018):

Duplicate of #3499

@lafriks commented on GitHub (Sep 12, 2018): Duplicate of #3499
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2318