Quickstart
A quick dive into getting started with Lore
A quick dive into getting started with Lore
In this step we'll learn how to customize our configuration for different environments, and fix our redirect issue in production.
You can view the finished code for this step by checking out the
production.3
branch of the completed project.
Lore is designed to support multiple deploy environments.
If you look inside the /config
folder, you'll see another folder named /env
that contains files named development.js
and production.js
. These files allow you to customize your configuration for different deploy environments.
The files in /config
are meant to be your defaults; the settings that make most sense in development. But other environments, like staging and production, will have different needs, like as a different API, or different feature flags, or different rules about error reporting.
The /env
folder is where you specify these differences, and they will override the default settings specified in /config
.
To get our application working on Now, we need to change the Auth0 configuration so that instead of redirecting the user to http://localhost:3000/auth/callback
after login, they are instead redirected to https://lore-quickstart.now.sh/auth/callback
(or whatever your chosen alias is set to).
To do this, open config/env/production.js
. If you ignore the comments, the file is empty, and looks like this:
export default {
}
Update that file to override the redirect URI for Auth0 by adding this code:
export default {
auth0: {
redirectUri: 'https://lore-quickstart.now.sh/auth/callback'
}
}
During the build process, the /config
folder is compiled into a single object, and made available through lore.config
. To illustrate, take this partial config folder:
config
|-- auth0.js
|-- actions.js
|-- ...
To convert the folder into an object, each file becomes a key/value pair, where the name of the file is the key, and what the file exports becomes the value.
That means the folder structure above would be converted into an object that looks like this:
config: {
auth0: {
// ...auth0.js...
},
actions: {
// ...actions.js..
}
}
The environment file in the /env
folder then overrides this object.
So if we want to override the redirectUri
property in the auth0.js
config, then we simply need to provide an auth0
key, and then specify the property we want to override, which generates the code we used above:
export default {
auth0: {
redirectUri: 'https://lore-quickstart.now.sh/auth/callback'
}
}
If everything went well, your application should still look like this (exactly the same).
Below is a list of files modified during this step.
export default {
auth0: {
redirectUri: 'https://lore-quickstart.now.sh/auth/callback'
}
}
In the next section we'll publish the application to the web.