Ember and Laravel - 2 Repos - 404 error

Hello, I’m working on a project with Ember as front and Laravel as backend. I’m fairly new to Ember and while trying to login it seems to not be picking up the correct API base URL from the Ember .env file when attempting to login via localhost:4200. (404 not found, screenshot attached).

For my local environment I have the API setup at api.app.test, and then in the .env file for the Ember app I have API_HOST=http://api.app.test .

I think what’s confusing me is the ember server (localhost:4200). I’m running the server using “ember server” and I also have xampp setup. My hosts file is set to 127.0.0.1 api.app.test. I’ve also tried setting up a virtual server by editing the httpd.conf and vhosts.conf files.

Regarding authentication, there is no registration function, users are added to the users table in database with preset bcrypt for passwords.

Any info is appreciated.

then in the .env file for the Ember app I have API_HOST=http://api.app.test

Are you consuming this value in your adapter? I can’t remember if Ember does this automatically but I don’t think it does.

You can also use the --proxy setting for ember-cli to run like this ember s --proxy api.app.test, which will proxy all requests from your app at localhost:4200 to whatever you specify.

EDIT: when I say “consuming in your adapter” I mean like this (assuming you’re using JSONAPIAdapter):

import DS from 'ember-data';

export default DS.JSONAPIAdapter.extend({
  host: 'https://api.example.com'
});
1 Like

Just as an additional hint: It should not be consumed directly but may be consumed in config/environment.js and imported from there in the adapter. Don’t forget to add support for dot env file through a plugin.

I would recommend to use proxy option for local development instead if possible. Using environment variables adds a lot of complexity for a little benefit in my opinion.

1 Like

After trying all the suggestions I found it was a separate issue with versioning within the environment.js file.

Thank you for helping me troubleshoot.