Skip to content

Commit 037c3fb

Browse files
committed
fix page view error by limit Referer
1 parent 0445e9c commit 037c3fb

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

api/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ const viewsEndpoint = new awsx.apigateway.API("bmpi-dev-post-views", {
2525

2626
console.log(`Getting count for '${route}'`);
2727

28+
let incr = event.headers["Referer"]?.includes("www.bmpi.dev") ? 1 : 0;
29+
2830
const client = new aws.sdk.DynamoDB.DocumentClient();
2931

3032
const result = await client.update({
3133
TableName: counterTable.name.get(),
3234
Key: { id: route },
3335
UpdateExpression: "SET hit = if_not_exists(hit, :zero) + :incr",
34-
ExpressionAttributeValues: { ":zero": 0, ":incr": 1 },
36+
ExpressionAttributeValues: { ":zero": 0, ":incr": incr },
3537
ReturnValues:"UPDATED_NEW",
3638
}).promise();
3739

0 commit comments

Comments
 (0)