Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 0b43cf6

Browse files
committed
Add basic form check
1 parent c0bad95 commit 0b43cf6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pages/api/wp/postComment.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ export default async function postComment(req, res) {
1212
// Retrieve props from request query params.
1313
const {author, authorEmail, authorUrl, postId, content} = req.query
1414

15+
// Basic check to see if the referer matches the host.
16+
// This is trivially easy to bypass, but it's a first step.
17+
if (
18+
!req.headers.referer ||
19+
!req.headers.referer.includes(req.headers.host)
20+
) {
21+
throw new Error('Unauthorized access')
22+
}
23+
1524
const commentResponse = await postCommentToPost(
1625
author,
1726
authorEmail,

0 commit comments

Comments
 (0)