301 redirect on Heroku
See original GitHub issueWorks great locally with runserver
or heroku local
(uses procfile/daphne) but on heroku I receive nothing but 301’s at any endpoint until the browser cancels the request (except for preflight OPTIONS):
app[web.1]: 2018-04-19 22:00:54,105 DEBUG HTTP 200 response started for ['10.67.237.54', 22273]
app[web.1]: 2018-04-19 22:00:54,099 DEBUG HTTP b'OPTIONS' request for ['10.67.237.54', 22273]
app[web.1]: 2018-04-19 22:00:54,106 DEBUG HTTP close for ['10.67.237.54', 22273]
app[web.1]: 2018-04-19 22:00:54,107 INFO "10.67.237.54" - - [07/Feb/1970:15:11:45 +0000] "OPTIONS /login HTTP/1.1" 200 - "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
app[web.1]: 2018-04-19 22:00:54,108 DEBUG HTTP response complete for ['10.67.237.54', 22273]
app[web.1]: 10.67.237.54:22273 - - [19/Apr/2018:22:00:54] "OPTIONS /login" 200 -
app[web.1]: 2018-04-19 22:00:54,166 DEBUG HTTP b'POST' request for ['10.67.237.54', 24540]
app[web.1]: 2018-04-19 22:00:54,171 DEBUG HTTP 301 response started for ['10.67.237.54', 24540]
app[web.1]: 2018-04-19 22:00:54,172 DEBUG HTTP close for ['10.67.237.54', 24540]
app[web.1]: 2018-04-19 22:00:54,172 INFO "10.67.237.54" - - [07/Feb/1970:15:11:45 +0000] "POST /login HTTP/1.1" 301 - "https://portal-stage.safechain.io/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
app[web.1]: 2018-04-19 22:00:54,173 DEBUG HTTP response complete for ['10.67.237.54', 24540]
app[web.1]: 10.67.237.54:24540 - - [19/Apr/2018:22:00:54] "POST /login" 301 -
app[web.1]: 2018-04-19 22:00:54,225 DEBUG HTTP b'GET' request for ['10.67.237.54', 27137]
app[web.1]: 2018-04-19 22:00:54,242 DEBUG HTTP 301 response started for ['10.67.237.54', 27137]
app[web.1]: 2018-04-19 22:00:54,243 DEBUG HTTP close for ['10.67.237.54', 27137]
app[web.1]: 2018-04-19 22:00:54,243 INFO "10.67.237.54" - - [07/Feb/1970:15:11:45 +0000] "GET /login HTTP/1.1" 301 - "https://portal-stage.safechain.io/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
app[web.1]: 2018-04-19 22:00:54,243 DEBUG HTTP response complete for ['10.67.237.54', 27137]
app[web.1]: 10.67.237.54:27137 - - [19/Apr/2018:22:00:54] "GET /login" 301 -
heroku[router]: at=info method=OPTIONS path="/login" host=api-stage.safechain.io request_id=40923337-04c1-4926-934d-9ea61074140b fwd="24.166.234.32" dyno=web.1 connect=2ms service=19ms status=200 bytes=430 protocol=https
heroku[router]: at=info method=GET path="/login" host=api-stage.safechain.io request_id=73f88c63-8140-4523-82f8-543ab40aab76 fwd="24.166.234.32" dyno=web.1 connect=0ms service=21ms status=301 bytes=252 protocol=https
heroku[router]: at=info method=POST path="/login" host=api-stage.safechain.io request_id=8005388e-f55f-4b73-b86b-c6492e3e1edc fwd="24.166.234.32" dyno=web.1 connect=2ms service=12ms status=301 bytes=252 protocol=https
app[web.1]: 2018-04-19 22:01:04,713 DEBUG HTTP b'POST' request for ['10.67.237.54', 30304]
app[web.1]: 2018-04-19 22:01:04,717 DEBUG HTTP 301 response started for ['10.67.237.54', 30304]
app[web.1]: 2018-04-19 22:01:04,718 DEBUG HTTP close for ['10.67.237.54', 30304]
app[web.1]: 2018-04-19 22:01:04,719 INFO "10.67.237.54" - - [07/Feb/1970:15:11:55 +0000] "POST /login HTTP/1.1" 301 - "https://portal-stage.safechain.io/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
app[web.1]: 2018-04-19 22:01:04,719 DEBUG HTTP response complete for ['10.67.237.54', 30304]
app[web.1]: 10.67.237.54:30304 - - [19/Apr/2018:22:01:04] "POST /login" 301 -
app[web.1]: 2018-04-19 22:01:04,771 DEBUG HTTP b'GET' request for ['10.67.237.54', 22432]
app[web.1]: 2018-04-19 22:01:04,773 DEBUG HTTP 301 response started for ['10.67.237.54', 22432]
app[web.1]: 2018-04-19 22:01:04,774 DEBUG HTTP close for ['10.67.237.54', 22432]
app[web.1]: 2018-04-19 22:01:04,774 INFO "10.67.237.54" - - [07/Feb/1970:15:11:55 +0000] "GET /login HTTP/1.1" 301 - "https://portal-stage.safechain.io/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
app[web.1]: 2018-04-19 22:01:04,774 DEBUG HTTP response complete for ['10.67.237.54', 22432]
app[web.1]: 10.67.237.54:22432 - - [19/Apr/2018:22:01:04] "GET /login" 301 -
heroku[router]: at=info method=GET path="/login" host=api-stage.safechain.io request_id=c3f120ac-6bb9-4a7a-ab9a-d1209ed4e0a3 fwd="24.166.234.32" dyno=web.1 connect=0ms service=6ms status=301 bytes=252 protocol=https
Procfile
web: daphne safechain.asgi:application -t 60 --access-log - --port $PORT --bind 0.0.0.0 -v2
worker: celery worker -A safechain -l info -Q api
Using the latest and greatest
aioredis==1.1.0
amqp==2.2.2
anyjson==0.3.3
asgiref==2.2.0
asn1crypto==0.24.0
async-timeout==2.0.1
attrs==17.4.0
autobahn==18.4.1
Automat==0.6.0
channels==2.0.2
channels-redis==2.1.1
chardet==3.0.4
chargebee==2.4.9
click==6.7
constantly==15.1.0
cryptography==2.2.2
daphne==2.1.0
Django==2.0.4
djangorestframework==3.8.2
djangorestframework-jsonapi==2.4.0
djangorestframework-jwt==1.11.0
hashids==1.2.0
hiredis==0.2.0
hyperlink==18.0.0
idna==2.6
incremental==17.5.0
redis==2.10.6
requests==2.18.4
Twisted==17.9.0
txaio==2.10.0
zope.interface==4.4.3
Thanks for all the hard work on this project!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Guru301 | Heroku Dev Center
Guru301 solves this problem by giving you one or more static IP addresses backed by rock-solid, high-availability redirect servers, allowing you ...
Read more >Redirecting www to Non-www Domain at Heroku
This article contains a list of the most common redirect scenarios for an application hosted on Heroku, along with some solutions for each...
Read more >CNAME to Heroku app results in 301 redirect - Server Fault
It turns out that the redirect was happening at the app level. Heroku's support confirmed that their router doesn't add any redirects.
Read more >How to redirect a Heroku domain to a custom domain?
A 301 redirect is a HTTP header. It can be set by the server or the app. You've chosen to outsource the server...
Read more >How to 301 redirect to another url with .htaccess on Heroku
recently i have changed my heroku's app name and url. ... How can i do a 301 redirect on heroku (my app is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also faced with that problem. Locally I use django with
SECURE_SSL_REDIRECT=False
, but in remote env I useSECURE_SSL_REDIRECT=True
. Daphne do not forward headers to django by default, and django always gethttp
and respond with redirect tohttps
.Running daphne with
--proxy-headers
params solved my problem.Do you plan to make documentation for daphne with more usage examples?
I’m afraid we can’t help with problems that only occur on Heroku - you’ll need to ask their support channels/forums instead. Sorry!