Change POST to GET for view counter
This commit is contained in:
parent
4f6d82bc7b
commit
8b7301d0da
2 changed files with 2 additions and 13 deletions
|
|
@ -315,7 +315,7 @@ const {
|
||||||
if (viewsEl?.dataset?.postId) {
|
if (viewsEl?.dataset?.postId) {
|
||||||
const postId = viewsEl.dataset.postId;
|
const postId = viewsEl.dataset.postId;
|
||||||
|
|
||||||
fetch(`/api/increment-views?postId=${postId}`, { method: 'POST' })
|
fetch(`/api/increment-views?postId=${postId}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.views !== undefined) {
|
if (data.views !== undefined) {
|
||||||
|
|
|
||||||
|
|
@ -46,18 +46,7 @@ function jsonResponse(data: object, status = 200): Response {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const POST: APIRoute = async ({ request, url }) => {
|
export const GET: APIRoute = async ({ request, url }) => {
|
||||||
if (request.method === 'OPTIONS') {
|
|
||||||
return new Response(null, {
|
|
||||||
status: 204,
|
|
||||||
headers: {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Methods': 'POST, OPTIONS',
|
|
||||||
'Access-Control-Allow-Headers': 'Content-Type',
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('[Increment Views] PB_URL:', POCKETBASE_URL);
|
console.log('[Increment Views] PB_URL:', POCKETBASE_URL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue