Skip to content

Consider using django.http.request.HttpRequest.build_absolute_uri() to obtain the absolute URI of a resource #2510

@candleindark

Description

@candleindark

Currently, the constant, django.conf.settings.DANDI_API_URL, is used in generation of the absolute URI of a resource provided by the service, such as:

api_url = f'{settings.DANDI_API_URL}/api'

(For more examples, check out https://github.com/search?q=repo%3Adandi%2Fdandi-archive+%22DANDI_API_URL%22+language%3APython&type=code&l=Python)

This approach relies on django.conf.settings.DANDI_API_URL being set to a value that's accessible to the client making the request and may become an issue if the DANDI Archive service is served through more than one domain. Consider using django.http.request.HttpRequest.build_absolute_uri() to obtain the absolute URI of a resource instead. It obtains an absolute URI based on the incoming request being handled.

Additional context
This issue originates from the discussion at #2386 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions