Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace not being set #4

Closed
dbinetti opened this issue Jul 26, 2014 · 16 comments · Fixed by #64
Closed

namespace not being set #4

dbinetti opened this issue Jul 26, 2014 · 16 comments · Fixed by #64

Comments

@dbinetti
Copy link

PREFACE: I am a complete and total noob, so forgive me if I'm missing something, but the namespace parameter does not seem to be honored when making requests of the API.

My config:

if (environment === 'development') {
    ENV.APP.API_HOST = 'http://localhost:8000';
    ENV.APP.API_NAMESPACE = 'api';
  }

In console:

Ember Debugger Active VM2701:161
GET http://localhost:8000/photos/?_=1406356846939 404 (NOT FOUND) vendor.js:9726
Error while processing route: photos vendor.js:17062

Notice that it is hitting the root url. Also, if I change my API itself to serve at the root, all is well.

@dustinfarris
Copy link
Owner

@dbinetti the API_NAMESPACE setting is on master (hasn't been released yet). Hoping to release 0.3.0 today.

@dustinfarris
Copy link
Owner

@dbinetti
Copy link
Author

super — thanks

On Sat, Jul 26, 2014 at 9:25 AM, Dustin Farris notifications@github.com
wrote:

@dbinetti check out the changelog: https://github.com/dustinfarris/ember-django-adapter/blob/master/CHANGELOG.md

Reply to this email directly or view it on GitHub:
#4 (comment)

@briarsweetbriar
Copy link

I'm still experiencing this issue with 0.4.0. Ember CLI is at 0.1.1. Any idea what might be happening?

@dustinfarris
Copy link
Owner

Looking into it. May need to update the way addon config is set.

@jsalva
Copy link
Contributor

jsalva commented Jan 23, 2015

I'm having the same issue using 0.5.1 from ember-cli; I noticed the docs example uses NAMESPACE rather than API_NAMESPACE. However, neither of these are changing adapter urls from root.

I'm using CLI 0.1.7

@dustinfarris
Copy link
Owner

@jsalva I've been having a lot of issues with ember-cli 0.1.7. I actually downgraded to 0.1.5.

It looks like 0.1.8 and 0.1.9 were released today. Let's try that out and see if it resolves anything.

@jsalva
Copy link
Contributor

jsalva commented Jan 23, 2015

sadly, upgrading to 0.1.9 didn't help.
It's not terribly difficult for me to set that stuff in an application adapter, but it'd be nice to be able to configure that in the environment.js too since it's what the docs recommend

@dustinfarris
Copy link
Owner

@jsalva it should work in the config definitely. It has been working for me, but something must have changed in ember-cli after 0.1.5. Something is wrong—thanks for bringing it up. I will open a new issue to fix this.

@dustinfarris
Copy link
Owner

@jsalva I cannot reproduce this. I just upgraded to 0.1.9 and everything is working.

Are you configuring the adapter in environment.js like this:

module.exports = function(environment) {
  var ENV = {
    APP: {
      API_NAMESPACE: 'my-api'
    }
  };

  ...

  return ENV;
};

@jsalva
Copy link
Contributor

jsalva commented Jan 25, 2015

Yep here it is:

//config/environment.js
module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'myapp',
    environment: environment,
    baseURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
      API_NAMESPACE: 'myapp/api1'
    },


  };
  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;

  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';

  }

  if (environment === 'production') {
    // set this to your production API
  }

  return ENV;
};

@dustinfarris
Copy link
Owner

@jsalva Do you have anything in app/adapters/?

@jsalva
Copy link
Contributor

jsalva commented Jan 25, 2015

at first, no (assumed the setting would configure an application adapter w/ my API_NAMESPACE for me. Eventually I just used ember cli to generate app/adapters/application.js and put the desired namespace explicitly in there.

@dustinfarris
Copy link
Owner

I really am having trouble reproducing. Have started a brand new project with ember new and the fiddled with the API_NAMESPACE setting and everything works as expected. Can you throw up a quick sample project on GitHub to demonstrate that I can clone and try?

@dustinfarris
Copy link
Owner

@jsalva nevermind. I have been able to confirm this.

@dustinfarris dustinfarris reopened this Jan 25, 2015
@dustinfarris
Copy link
Owner

@jsalva we aren't setting a default API_HOST which I believe is the main issue here. Your namespace is indeed being respected, but it doesn't matter because it was pointed at the ember server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants