florgon / cc-api

Link shortening API written in Flask using Florgon Ecosystem (APIs).
https://api-cc.florgon.com/v1
GNU Affero General Public License v3.0
4 stars 1 forks source link

API returns wrong link to stats and qr #27

Closed stepanzubkov closed 1 year ago

stepanzubkov commented 1 year ago

Flask's url_for with _external=True builds url using internal docker network and API gives wrong link:

"_links": {
        "qr": {
          "href": "https://florgon-cc-api/v1/urls/bdWxN2/qr"
        },
        "stats": {
          "href": "https://florgon-cc-api/v1/urls/bdWxN2/stats"
        }
      }

The links should be https://api-cc.florgon.com/v1/urls/xxxxxx/qr and https://api-cc.florgon.com/v1/urls/xxxxxx/stats

stepanzubkov commented 1 year ago

Maybe we should define property in config like CC_API_HOST?

kirillzhosul commented 1 year ago

You should check the host from request / server information (but if you checking it from HOST header you should be sure that there no vulnerabilities)

kirillzhosul commented 1 year ago

This is caused by host-name from docker (florgon-cc-api is the docker hostname)

kirillzhosul commented 1 year ago

And also, for sure, you also should checkout link (url) to the open page (cc.florgon.com)

stepanzubkov commented 1 year ago

When I deploy API on localhost, It gives normal urls. But on production It gives url with internal docker network name. I don't know why.

stepanzubkov commented 1 year ago

Fixed by f52d9ad and 1e38aac