Channels: Enabling channels breaks `FORCE_SCRIPT_NAME`

Created on 13 Apr 2018  路  5Comments  路  Source: django/channels

Hi all!

Today I suddenly figured out that enabling Channels breaks URL "routing" inside Django Admin when FORCE_SCRIPT_NAME is set. I have Django running behind Nginx reverse proxy with /api/ URL prefix. To make Django respect this prefix I set FORCE_SCRIPT_NAME = '/api' in the Django setting file. Everything works fine until I enable Channels by INSTALLED_APPS += ['channels']. After this Django Admin login screen POSTs data the wrong URL, the one without /api/ prefix. If I disable Channels it works fine again. I simply do not know where to dig further. Any help is appreciated.

My setup:

  • channels (2.1.0)
  • daphne (2.1.0)
  • Django (2.0.4)
  • Ubuntu Linux 16.04
bug exbeginner

Most helpful comment

Hey! I'm at the DjangoCon EU sprints. I'm working on this issue.

All 5 comments

Yup, there is no support for this yet as it's overriding a WSGI-specific thing and we'd need to make sure it interoperates correctly. You can instead use the --root-path option to Daphne to provide this right now until this is fixed.

@andrewgodwin Thank you. I will use --root-path for now.

Hey! I'm at the DjangoCon EU sprints. I'm working on this issue.

Hey @andrewgodwin! Opened the #1064 PR. Could you check if everything is OK?
Thank you for all the help :)

Looks lovely - thanks for your work on that!

Was this page helpful?
0 / 5 - 0 ratings