Django Token Authentication doesn't work when I access to server via domain name

I have a Django application with token authentication and I serve it via Apache2. When I do my auth required requests to the server with the domain name it returns with 401 Unauthorized HTTP error. When I do it with ip:port, it returns success. Same token is sent to the server. What might cause that? May apache server be related to this?

Here is my apache config:

<VirtualHost *:80>
        ServerAdmin ...
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /static /home/cuneyttyler/knowledgebase/knowledge-base-django/static
        <Directory /home/cuneyttyler/knowledgebase/knowledge-base-django/static>
                Require all granted

        Alias /media /home/cuneyttyler/knowledgebase/knowledge-base-django/media
        <Directory /home/cuneyttlyer/knowledgebase/knowledge-base-django/media>
                Require all granted

        <Directory /home/cuneyttyler/knowledgebase/knowledge-base-django/knowledgebase_python>
                        Require all granted

        WSGIDaemonProcess knowledge-base-django python-path=/home/cuneyttyler/knowledgebase/knowledge-base-django python-home=/home/cuneyttyler/knowledgebase/knowledge-bas>
        WSGIProcessGroup knowledge-base-django
        WSGIScriptAlias / /home/cuneyttyler/knowledgebase/knowledge-base-django/knowledgebase_python/

>Solution :

Apache does not pass on the Authorization header by default, you need to add the following to your VirtualHost config and restart Apache

WSGIPassAuthorization On

Leave a Reply