So this might be too late, but... This happens to me if there's a syntax error in my code. Check your syntax with esprima:
http://esprima.org/demo/validate.html
You can also open the browser console, and you should see an Amazon error HTTP 502, which is not "Bad Gateway" but actually an internal server error.