Skip to content

Commit 0dae860

Browse files
committed
more SSR notes
1 parent 5e6f7e4 commit 0dae860

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

notes/20-server-rendering.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,29 @@ Ember's server rendering technology is called "Fastboot". Effectively, it's a sm
44

55
The idea is that you should _not_ be writing two apps (despite needing to run on two different environments). In order to do this, you'll need to stick to the _overlap_ of browser and Node.js APIs.
66

7-
![](./img/20-server-rendering/js-envs.png)
7+
![js environments](./img/20-server-rendering/js-envs.png)
8+
9+
First, let's install fastboot to enable server-rendering
10+
11+
```
12+
ember install ember-cli-fastboot
13+
```
14+
15+
Open your [`config/environment.js`](../config/environment.js), and add a `fastboot` object as a top-level property of the `ENV` property you'll find there.
16+
17+
```diff
18+
+ fastboot: {
19+
+ hostWhitelist: [/localhost/],
20+
+ },
21+
APP: {
22+
```
23+
24+
We'll have to refactor our `auth` service so that it doesn't use any browser-specific APIs.
25+
26+
To do this we can install `ember-cookies`, a unified abstraction that can provide us with a way of dealing with cookies both in node and in a browser environment
27+
28+
```
29+
ember install ember-cookies
30+
```
31+
32+
Now let's stop and restart ember-cli -- we should see that the app is now being served with fastboot.

0 commit comments

Comments
 (0)