Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get an Error 400: Bad Request on custom Heroku domain, but works fine on foo.herokuapp.com

I've just pushed a Django project up to Heroku. It works fine at http://rtd-staging.herokuapp.com/rtd2015/, but for some reason I get a 400 error: Bad Request when I visit it using: http://staging.researchthroughdesign.org/rtd2015/

I know that the CNAME was setup correctly because during the process of pushing up to heroku it said that the Heroku app had crashed, so it was definitely pointing to the correct app.

Here is the log for the error:

2014-04-23T18:32:29.981976+00:00 heroku[router]: at=info method=GET path=/ host=staging.researchthroughdesign.org request_id=b8fe3ac9-e062-493b-b3bf-862c60e4001b fwd="82.34.146.252" dyno=web.1 connect=1ms service=7ms status=400 bytes=226
like image 985
David Ingledow Avatar asked Apr 23 '14 18:04

David Ingledow


2 Answers

You have to set your website domain as an allowed host. Place this in your ./app/settings/settings.py:

ALLOWED_HOSTS = [".herokuapp.com", ".researchthroughdesign.org"]

In production you can even remove .herokuapp.com

like image 90
Stéphane Bruckert Avatar answered Nov 04 '22 06:11

Stéphane Bruckert


heroku config:set DJANGO_ALLOWED_HOSTS=.example.com,example.herokuapp.com
like image 9
Léo Chaz Maltrait Avatar answered Nov 04 '22 07:11

Léo Chaz Maltrait