Skip to content

API with or without Host

Compare
Choose a tag to compare
@vishalanandl177 vishalanandl177 released this 12 Nov 17:16
· 112 commits to master since this release

You can specify the endpoint of API should have an absolute URI or not by setting this variable in DRF settings.py file.

Set DRF_API_LOGGER_PATH_TYPE = 'ABSOLUTE' in settings.py
Possible values are ABSOLUTE, FULL_PATH, or RAW_URI.

Considering we are accessing the following URL: http://127.0.0.1:8000/api/v1/?page=123
DRF_API_LOGGER_PATH_TYPE possible values are:

  1. ABSOLUTE (Default) :
    Function used request.build_absolute_uri()
    Output: http://127.0.0.1:8000/api/v1/?page=123

  2. FULL_PATH
    Function used request.get_full_path()
    Output: /api/v1/?page=123

  3. RAW_URI
    Function used request.get_raw_uri()
    Output: http://127.0.0.1:8000/api/v1/?page=123

Note: Similar to ABSOLUTE but skip allowed hosts protection, so may return insecure URI.