0xfurai / 0xfurai/peekaping

Swagger doc.json has hard coded host to localhost:8034

Đang mở Phù hợp với người mới
#238 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
1.2k
Fork
69
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Describe the bug**
I am testing running the API through a reverse proxy domain using the microservice docker images, however the Swagger host seems to be hard coded, e.g. in `doc.json`:

```json
{
"schemes": [],
"swagger": "2.0",
"info": {
"description": "",
"title": "Peekaping API",
"contact": {},
"version": "0.0.44"
},
"host": "localhost:8034",
"basePath": "/api/v1",
"paths": {
...
```

This means I can't actually run requests through myapiurl.com/swagger/index.html because it tries to connect to `localhost:8034` instead of `myapiurl.com`.

**Database**
- postgresql

**To Reproduce**
Steps to reproduce the behavior:
1. Have the API proxying through a domain, eg. https://myapiurl.com.
2. Visit https://myapiurl.com/swagger/index.html
3. See the base URL does not match domain.
4. Visit https://myapiurl.com/swagger/doc.json
5. See the host property is hard coded: ` "host": "localhost:8034",`

**Expected behavior**
The Swagger Base URL should match the domain so requests can be sent using the Swagger UI to the domain instead of http://localhost:8034

**Screenshots**
Image

**Desktop (please complete the following information):**
- OS: Linux
- Browser: Brave
- Version: 1.84 / Chromium 142.0.7444.176

**Additional context**
None

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The issue points to a hardcoded host in the Swagger doc.json file. Look for the code that generates this JSON, likely in a swagger or API documentation setup. Check configuration files or environment variables that should control the host. The goal is to make the host dynamic based on the request domain, not fixed to localhost:8034. Test by running the service behind a reverse proxy and verifying the Swagger UI uses the correct domain.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
api, documentation
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
65/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.