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

Mirage is not working with ember-electron #497

Closed
BryanHunt opened this Issue Jan 10, 2016 · 14 comments

Comments

Projects
None yet
7 participants
@BryanHunt
Copy link

BryanHunt commented Jan 10, 2016

If you run ember electron with Mirage, you get an error message of the form:

Mirage: Your Ember app tried to GET '/radio/memory-blocks', but there was no route defined to handle this request. Define a route that matches this path in your mirage/config.js file. Did you forget to add your namespace?unhandledRequest @ server.js:76

Running ember server works just fine.

@samselikoff

This comment has been minimized.

Copy link
Owner

samselikoff commented Jan 10, 2016

Hm. When you built your Ember app for Electron is there a config option for that environment that changes the host/subdomain/namespace of the API requests?

@BryanHunt

This comment has been minimized.

Copy link
Author

BryanHunt commented Jan 10, 2016

There are no documented configuration options for ember electron. The only config setting you need to change for electron is using locationType: 'hash'.

@samselikoff

This comment has been minimized.

Copy link
Owner

samselikoff commented Jan 10, 2016

And you don't change anything with baseUrl in config/environment?

Unfortunately I've never used Electron so there'd need to be some further investigation done to figure out the problem. This is not high on my priority list right now, but I'm happy to offer guidance if someone wants to explore.

@BryanHunt

This comment has been minimized.

Copy link
Author

BryanHunt commented Jan 10, 2016

No, baseUrl stays the same. I tried debugging the problem, but got lost in a state machine. I did verify that the endpoints are registered in config.js. Running ember-electron is as simple as:

ember install ember-electron
ember electron
@hugoruscitti

This comment has been minimized.

Copy link

hugoruscitti commented Feb 9, 2016

I have a same issue today, i think it's related to file:// urls...

Anyway, it's work for me when i sets the "urlPrefix" in the first line of mirage/config.js, like this:

export default function() {
  this.urlPrefix = '/';

  // this.get('/projects');
[etc...]

maybe it's works for you too @BryanHunt?

cc: @felixrieseberg

@anulman

This comment has been minimized.

Copy link
Contributor

anulman commented Feb 12, 2016

@hugoruscitti @BryanHunt can confirm, this is a similar config we've had to use in ember-cli-cordova.

One strategy I like is to set the urlPrefix via config, which lets us set different base api URLs for dev / prod:

// config/environment.js
var ENV = {
// ...
  api: {
    host: 'http://foo.com'
    namespace: 'baz'
  }
}

if (environment === 'development') {
  ENV.api.host = 'http://localhost:3000'
}

if (environment === 'test') {
  ENV.api.host = '/'
}
// adapters/application.js
import DS from 'ember-data';
import ENV from 'app-name/config/environment';

export default DS.JSONAPIAdapter.extend({
  host: ENV.api.host,
  namespace: ENV.api.namespace
});
// mirage/config.js
import ENV from 'app-name/config/environment';

export default function() {
  this.urlPrefix = `${ENV.api.host}/${ENV.api.namespace}`
// ...
}
@gesmith

This comment has been minimized.

Copy link

gesmith commented Feb 24, 2016

@hugoruscitti This problem was very frustrating, but your suggestion fixed it for me! Thanks!

@samselikoff samselikoff added the icebox label Jun 4, 2016

@acorncom

This comment has been minimized.

Copy link
Collaborator

acorncom commented Sep 22, 2016

@BryanHunt @gesmith Is there anything else that is needed here or should we close this issue? Sounds like it's more a case of "need to add some documentation on how to make this work with Electron"?

@anulman

This comment has been minimized.

Copy link
Contributor

anulman commented Sep 22, 2016

+1 to adding to docs. I've got a contrib waiting with a new defaultPassthrough URL (related to ember-electron, actually ;), so would be happy to take a stab at drafting a notice to cordova + electron consumers.

@BryanHunt

This comment has been minimized.

Copy link
Author

BryanHunt commented Sep 22, 2016

I had to step away from ember-electron for a bit. Updating the docs and closing this is fine with me.

@acorncom

This comment has been minimized.

Copy link
Collaborator

acorncom commented Sep 30, 2016

@anulman I'll close this for now, but would be happy to see a PR on this. Ideally Mirage would be able to detect it was running inside of electron ... 😀

@acorncom acorncom closed this Sep 30, 2016

@samselikoff samselikoff removed the icebox label Sep 30, 2016

@anulman

This comment has been minimized.

Copy link
Contributor

anulman commented Sep 30, 2016

@acorncom I think that can be done, although it creates a weak dep on ember-electron via process.env.EMBER_CLI_ELECTRON.

Been meaning to do this all week, but meetings popped up that were a priority. I expect to ship a PR by Mon

(Edit: the log spew vs. inter-branch diff management has been a subtle thorn all week 😂 )

@felixrieseberg

This comment has been minimized.

Copy link

felixrieseberg commented Sep 30, 2016

I'm happy to promise that we'll always have that property set to true if
running in Electron 👍

On Thursday, September 29, 2016, Aidan Nulman notifications@github.com
wrote:

@acorncom https://github.com/acorncom I think that can be done,
although it creates a weak dep on ember-electron via
process.env.EMBER_CLI_ELECTRON.

Been meaning to do this all week, but meetings popped up that were a
priority. I expect to ship a PR by Mon


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#497 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABXFb7RkuV2MwD_ZEv33NLNZ3mYQlYgWks5qvFKmgaJpZM4HB4Z4
.

All the best,
Felix

@anulman

This comment has been minimized.

Copy link
Contributor

anulman commented Oct 19, 2016

@felixrieseberg fun fact about the above—that property doesn't seem to be true in a packaged app ;)

To get around it, we now manually read the .env file with dotenv directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment