Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ invalidate:
CLOUDFRONT_DISTRIBUTION_ID="${CLOUDFRONT_DISTRIBUTION_ID}" node create-invalidation.js

listinvalidations:
aws cloudfront list-invalidations --distribution-id "" | head
aws cloudfront list-invalidations --distribution-id "${CLOUDFRONT_DISTRIBUTION_ID}" | tail | head -25

test:
DEBUG=prerendercloud PRERENDER_SERVICE_URL="https://service.prerender.cloud" ./node_modules/jasmine/bin/jasmine.js
14 changes: 12 additions & 2 deletions deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ if (!process.env["CLOUDFRONT_DISTRIBUTION_ID"]) {

CLOUDFRONT_DISTRIBUTION_ID = process.env["CLOUDFRONT_DISTRIBUTION_ID"];

const viewjoin = 'Lambda-Edge-Prerendercloud-' + process.env["color"] + '-viewerRequest';
const originjoin = 'Lambda-Edge-Prerendercloud-' + process.env["color"] + '-originRequest';
const originName1 = process.env["originName"];
const viewerName1 = process.env["viewerName"];
const viewer = viewjoin //+ ':' + viewerName1;
const origin = originjoin //+ ':' + originName1;
console.log(viewer);
console.log(origin);

const lambdaMappings = [
{
FunctionName: "Lambda-Edge-Prerendercloud-dev-viewerRequest",
FunctionName: viewer,
EventType: "viewer-request"
},
{
FunctionName: "Lambda-Edge-Prerendercloud-dev-originRequest",
FunctionName: origin,
EventType: "origin-request"
}
];
console.log(lambdaMappings);

const AWS = require("aws-sdk");
AWS.config.region = "us-east-1";
Expand Down
4 changes: 2 additions & 2 deletions handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const resetPrerenderCloud = () => {
// 1. prerenderToken (API token, you'll be rate limited without it)
// Get it after signing up at https://www.prerender.cloud/
// note: Lambda@Edge doesn't support env vars, so hardcoding is your only option.
// prerendercloud.set("prerenderToken", "mySecretToken")
prerendercloud.set("prerenderToken", "")

// 2. protocol (optional, default is https)
// use this to force a certain protocol for requests from service.prerender.cloud to your origin
Expand All @@ -35,7 +35,7 @@ const resetPrerenderCloud = () => {
// set it, the only info we'd have access to during Lambda@Edge runtime is the host of the origin (S3)
// which would require additional configuration to make it publicly accessible (and it just makes things more confusing).
// example value: example.com or d1pxreml448ujs.cloudfront.net (don't include the protocol)
// prerendercloud.set("host", "");
prerendercloud.set("host", "<red.test.com ex:DNS>");

// 4. removeTrailingSlash (recommended)
// Removes trailing slash from URLs to increase prerender.cloud server cache hit rate
Expand Down
12 changes: 6 additions & 6 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ provider:
role: LambdaEdgeRole

# you can overwrite defaults here
# stage: dev
stage: ${env:stage}

# you can define service wide environment variables here
# environment:
# variable1: value1

environment:
viewerName: dev
originName: dev
# you can add packaging information here
#package:
# include:
Expand All @@ -31,7 +31,7 @@ provider:
# - exclude-me-dir/**

functions:
viewerRequest:
viewerRequest:
handler: handler.viewerRequest
timeout: 5
originRequest:
Expand All @@ -57,7 +57,7 @@ resources:
Policies:
- PolicyName: LambdaEdgeExecutionRole
PolicyDocument:
Version: "2012-10-17"
# Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
Expand Down