tonycoco / heroku-buildpack-ember-cli

A Heroku Buildpack for Ember CLI Applications
MIT License
321 stars 121 forks source link

Proxy using API_URL not working #111

Closed hoIIer closed 8 years ago

hoIIer commented 8 years ago

Hello,

I just created a new heroku client app and heroku backend django app in the exact same configuration as another deployment that works...

I set the API_URL value to that of my api however it is not making requests to my api. In my api logs I don't see anything and on the client it's showing 404...

Any ideas?

heroku config -a craft-frontend-production
=== craft-frontend-production Config Vars
API_PREFIX_PATH:
API_URL:               http://craft-backend-production.herokuapp.com/
EMBER_ENV:             production
NGINX_WORKERS:         4
NPM_CONFIG_PRODUCTION: true
REBUILD_ALL:           true
tonycoco commented 8 years ago

On your client app, where are requests to that API coming from? That should dictate the API_PREFIX_PATH

hoIIer commented 8 years ago

@tonycoco my django api serves at craft-backend-production.herokuapp.com/api/v1 and in my ember config/environment.js I have:

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'craft-frontend',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    namespace: 'api/v1',
    ...

and in app/adapters/application.coffee

import DS from 'ember-data'

export default DS.RESTAdapter.extend
  namespace: 'api/v1'

what do you suggest I set it to?

hoIIer commented 8 years ago

@tonycoco this is my current heroku config and it's not working (you can view site at http://www.craft710.com and open console while loading the page and notice 404 xhr request to /api/v1/partners)

heroku config -a craft-frontend-production
=== craft-frontend-production Config Vars
API_PREFIX_PATH:       /api/v1/
API_URL:               http://craft-backend-production.herokuapp.com/
EMBER_ENV:             production
NGINX_WORKERS:         4
NPM_CONFIG_PRODUCTION: true
tonycoco commented 8 years ago

@erichonkanen ahh, that explains it... the build pack's nginx config actually strips off the /api/v1/ from the subsequent requests to the "backend". Try this...

API_URL:               http://craft-backend-production.herokuapp.com/api/v1/

In the Heroku config.

hoIIer commented 8 years ago

@tonycoco ok should I unset the API_PREFIX_PATH? I unset it (made it blank) and set the API_URL as you said above but still no luck... :/

In chrome debug network tab I see:

Cannot GET /api/v1/partners

From the logs:

2015-10-20T04:44:48.256171+00:00 heroku[router]: at=info method=GET path="/api/v1/stores?query=denver" host=www.craft710.com request_id=b2563928-82ca-4f3a-814c-3427da3c138c fwd="108.89.116.84" dyno=web.1 connect=0ms service=5ms status=404 bytes=1658

Also I saw this in the logs, is live reload supposed to be disabled or should this be appearing?

2015-10-20T04:44:33.813962+00:00 heroku[router]: at=info method=GET path="/ember-cli-live-reload.js" host=www.craft710.com request_id=0b6fbb3b-5a15-4a0a-a137-78721230a3c4 fwd="108.89.116.84" dyno=web.1 connect=1ms service=22ms status=200 bytes=1923

Im also seeing below but it must be a separate issue.. maybe video issue?:

 Process running mem=661M(129.2%)
Error R14 (Memory quota exceeded)
hoIIer commented 8 years ago

this was command I ran just for sanity check heroku config:set API_PREFIX_PATH=http://craft-backend-production.herokuapp.com/api/v1/ -a craft-frontend-production

hoIIer commented 8 years ago

I'm actually seeing this and it is confusing me... is this normal for the ember server to be running? I thought the buildpack was using nginx to serve?

2015-10-20T04:49:11.342819+00:00 app[web.1]: Livereload server on port 53995
2015-10-20T04:49:11.366165+00:00 app[web.1]: Serving on http://localhost:22466/
2015-10-20T04:49:16.227566+00:00 heroku[api]: Remove API_URL config vars by scott@craft710.com
2015-10-20T04:49:16.227566+00:00 heroku[api]: Release v36 created by scott@craft710.com
2015-10-20T04:49:16.692677+00:00 heroku[web.1]: State changed from up to starting
2015-10-20T04:49:19.050505+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-10-20T04:49:20.275066+00:00 heroku[web.1]: Process exited with status 143
2015-10-20T04:49:27.194904+00:00 heroku[web.1]: Starting process with command `npm start`
2015-10-20T04:49:29.398965+00:00 app[web.1]:
2015-10-20T04:49:29.398976+00:00 app[web.1]: > craft-frontend@0.0.0 start /app
2015-10-20T04:49:29.398977+00:00 app[web.1]: > ember server
2015-10-20T04:49:29.398978+00:00 app[web.1]:
2015-10-20T04:49:31.525513+00:00 app[web.1]: Future versions of Ember CLI will not support v4.2.1. Please update to Node 0.12 or io.js.
2015-10-20T04:49:31.526725+00:00 app[web.1]: version: 0.2.7
2015-10-20T04:49:32.127002+00:00 app[web.1]:
2015-10-20T04:49:32.288355+00:00 app[web.1]: Could not find watchman, falling back to NodeWatcher for file system events.
2015-10-20T04:49:32.126997+00:00 app[web.1]: 1.13.8
2015-10-20T04:49:32.288425+00:00 app[web.1]: Visit http://www.ember-cli.com/#watchman for more info.
2015-10-20T04:49:32.992129+00:00 app[web.1]: bootstrap-sassy config:  all JS enabled, glyphicons enabled
2015-10-20T04:49:35.248843+00:00 app[web.1]: Livereload server on port 75461
2015-10-20T04:49:35.279587+00:00 app[web.1]: Serving on http://localhost:43932/
hoIIer commented 8 years ago

ugh that might have been my clue! w-t-f it looks like the buildpack wasnt set on this branch somehow! hoping that is the issue

also explains why the app seems slow as shit

hoIIer commented 8 years ago

that was it! wow and it fixed my other issues with slow speed lol.. thanks for the help...