Skip to content

fix: visitor counter 403 on Vercel#8

Merged
anurag629 merged 1 commit intodevfrom
fix/visitor-counter-cors
Feb 27, 2026
Merged

fix: visitor counter 403 on Vercel#8
anurag629 merged 1 commit intodevfrom
fix/visitor-counter-cors

Conversation

@anurag629
Copy link
Member

@anurag629 anurag629 commented Feb 27, 2026

Summary

  • Add Content-Type: application/json header to the visitor counter POST request in the footer
  • Vercel's CSRF protection blocks POST requests without this header, returning 403 Forbidden with "Cross-site POST form submissions are forbidden"

Root cause

Vercel blocks POST requests with form-like content types (application/x-www-form-urlencoded, multipart/form-data, text/plain). A fetch() with method: 'POST' and no explicit Content-Type defaults to text/plain, which triggers the block.

Test plan

  • Deploy to Vercel and verify /api/visitors POST returns 200 with JSON
  • No more 403 Forbidden or JSON parse errors in browser console
  • Visitor counts update correctly in the footer

Vercel CSRF protection blocks POST requests without explicit
Content-Type: application/json, returning 403 Forbidden.
@vercel
Copy link

vercel bot commented Feb 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ogcops Ready Ready Preview, Comment Feb 27, 2026 10:14am

Request Review

@anurag629 anurag629 merged commit 38c7967 into dev Feb 27, 2026
3 checks passed
@anurag629 anurag629 deleted the fix/visitor-counter-cors branch February 27, 2026 10:15
anurag629 added a commit that referenced this pull request Feb 27, 2026
* ci: enforce dev → main PR flow (#2)

* docs: improve README hero image, add contributors section (#1)

Switch hero from blog-minimal-dark to github-readme-hero template with
brand accent color. Add contrib.rocks contributors grid. Condense
contributing section to avoid redundancy with CONTRIBUTING.md.

* ci: add workflow to restrict PRs targeting main to dev branch only

PRs targeting main from any branch other than dev will fail the
PR Target Check. This enforces the flow: feature branches → dev → main.

* ci: retrigger checks after base branch change

* ci: run CI on PRs targeting dev branch too

* feat: Raycast-inspired UI/UX redesign (#3)

* feat: Raycast-inspired UI/UX redesign across all pages

Redesign the entire site with a polished, premium feel inspired by Raycast:

- Design system: enhanced shadows, gradients, glassmorphism, animations
- Header: frosted glass, gradient border, nav hover pills
- Homepage: hero glow, equal-width bento category grid, feature cards,
  vertical timeline, terminal chrome API teaser, OSS banner
- Templates gallery: search bar, filter pills, card hover glow
- Editor: dot-grid canvas, refined panels, gradient export button
- API docs: sidebar icons, terminal chrome code blocks, copy buttons
- 404 page: SVG illustration, floating shapes, gradient text
- Footer: 3-column grid layout with gradient top border
- Layout: Astro View Transitions for smooth page navigation
- Fix thumbnail API rendering templates at 600x315 viewport (cropping)
  instead of 1200x630 with resvg scale-down (showing full template)

* feat: add GitHub stars and visitor counter utilities

Add supporting libs for GitHub star count, Upstash Redis visitor
counter, and the /api/visitors endpoint. Include .env.example for
required environment variables.

* fix: add Content-Type header to visitor counter POST request (#8)

Vercel CSRF protection blocks POST requests without explicit
Content-Type: application/json, returning 403 Forbidden.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant