Whitelist origins depending on domain/debug setting (bug 1075515)

Also, add loop dev URL on dev or if debug is True.