You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-14Lines changed: 8 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,25 +53,19 @@ Note, you **will not be creating** a CloudFront "custom error response" that red
53
53
54
54
#### 3. Install Dependencies
55
55
56
-
( Node v6, yarn >= v1.1.0 ) (note, yarn before v1.1.0 has a bug that causes dev deps to be installed)
56
+
( Node v8, yarn >= v1.1.0 ) (note, yarn before v1.1.0 has a bug that causes dev deps to be installed)
57
57
58
58
`$ yarn install`
59
59
60
60
#### 4. Hardcode your prerender.cloud auth token
61
61
62
62
Edit [handler.js](handler.js) and set your prerender.cloud API token (cmd+f for `prerenderToken`)
63
63
64
-
#### 5. Hardcode your CloudFront URL
64
+
#### 5. Edit any other configs (optional)
65
65
66
-
Edit [handler.js](handler.js) and set your CLoudFront distribution URL or whatever domain is aliased to your CloudFront distribution (cmd+f for `host`).
66
+
e.g. `botsOnly`, `removeTrailingSlash` in [handler.js](handler.js)
67
67
68
-
If you don't set this, the Lambda@Edge will see the host as the S3 origin, which means that's what prerender.cloud will attempt to hit which means you'd need to configure your s3 origin to be publicly accessible. Plus, it's usually better for prerender.cloud to prerender against the canonical URL, not the S3 origin.
69
-
70
-
#### 6. Edit any other configs (optional)
71
-
72
-
e.g. `botsOnly`, `removeTrailingSlash`
73
-
74
-
#### 7. Remove CloudFront custom error response for 404->index.html
68
+
#### 6. Remove CloudFront custom error response for 404->index.html
75
69
76
70
**(this step is only necessary if you are using an existing CloudFront distribution)**
77
71
@@ -85,7 +79,7 @@ It has to be removed because it prevents the execution of the viewer-request fun
85
79
4. make note of the TTL settings (in case you need to re-create it)
86
80
5. and delete the custom error response (because having the custom error response prevents the `viewer-request` function from executing).
87
81
88
-
#### 8. Add `s3:ListBucket` permission to CloudFront user
82
+
#### 7. Add `s3:ListBucket` permission to CloudFront user
89
83
90
84
**(this step is only necessary if you want 404s to work)**
91
85
@@ -112,22 +106,22 @@ If you're not editing an IAM policy specifically, the UI/UX checkbox for this in
112
106
113
107
You can modify the content of the 404 page in [handler.js](handler.js)
114
108
115
-
#### 9. Lambda@Edge function Deployment (only needs to be done once)
109
+
#### 8. Lambda@Edge function Deployment (only needs to be done once, or whenever you `git pull` from this repo)
116
110
117
111
1. Make sure there's a "default" section in your ~/.aws/credentials file with aws_access_key_id/aws_secret_access_key that have any of the following permissions: (full root, or see [serverless discussion](https://github.com/serverless/serverless/issues/1439) or you can use the following policies, which are _almost_ root: [AWSLambdaFullAccess, AwsElasticBeanstalkFullAccess])
118
112
2. now run: `$ CLOUDFRONT_DISTRIBUTION_ID=whateverYourDistributionIdIs make deploy`
119
113
3. See the created Lambda function in Lambda: https://console.aws.amazon.com/lambda/home?region=us-east-1#/functions
120
114
4. See the created Lambda function in CloudFront: (refresh it, click your distribution, then the behaviors tab, then the checkbox + edit button for the first item in the list, then scroll to bottom of that page to see "Lambda Function Associations")
121
115
122
-
#### 10. Deployment (of your single-page application)
116
+
#### 9. Deployment (of your single-page application)
123
117
124
118
1. sync/push the files to s3
125
119
2. invalidate CloudFront
126
120
3. you're done (no need to deploy the Lambda@Edge function after this initial setup)
127
121
128
122
caveat: note that prerender.cloud has a 5-minute server cache that you can disable, see `disableServerCache` in [handler.js](/handler.js)
129
123
130
-
#### 11. You're done!
124
+
#### 10. You're done!
131
125
132
126
Visit a URL associated with your CloudFront distribution. **It will take a few seconds** for the first request (because it is pre-rendered on the first request). If for some reason the pre-render request fails or times out, the non-pre-rendered request will be cached.
0 commit comments