Skip to content

fix(ads): stop loading Ezoic and AdSense scripts for premium users - #254

Merged
Snouzy merged 1 commit into
mainfrom
fix/premium-users-still-see-ads
Sep 20, 2026
Merged

Snouzy merged 1 commit into
mainfrom
fix/premium-users-still-see-ads

Conversation

@Snouzy

@Snouzy Snouzy commented Sep 20, 2026

Copy link
Copy Markdown
Owner

The bug

Paying users still see ads.

The cause

app/[locale]/layout.tsx put the AdSense and Ezoic scripts in <head> for every visitor. AdWrapper hides the React placements for premium users, and that part works. But Ezoic places anchor, side rail, interstitial and video ads by itself, outside React, so AdWrapper never sees them. Those formats were turned on in 15360f2 and 77f25a9.

AdBlockerForPremium only targets AdSense auto ads, and it runs after the scripts have loaded.

Ruled out: every ad component goes through AdWrapper, no caller passes forceShow, customSession reads isPremium from the database on each get-session, and no active subscriber has isPremium = false.

The fix

AdScripts is a server component. It calls serverAuth() and renders no script for a premium user. The layout renders <AdScripts /> in place of the inline block. If the session lookup throws, the ads stay on, so a database error cannot take every page down.

Sign-in goes through callbackURL, which is a full page load, so the layout is rendered again after login. Pages were already rendered per request (cache-control: no-store in production), so this costs no static generation.

Verified

tsc and eslint exit 0, 31 tests pass. On next dev, an anonymous visitor still gets all the ad scripts in the HTML.

The premium case is covered by AdScripts.test.tsx with a mocked session. The test fails when the premium check is removed. It was not exercised with a real premium session: after deploy, check with a premium account that the HTML has no sa.min.js.

vitest.config.ts gains the @ alias and *.test.tsx. This test needs both.

Not done here

AdBlockerForPremium and AdSenseAutoAds have no job left. Left alone deliberately, worth their own change.

The root layout loaded the ad scripts for every visitor. AdWrapper hides
the React placements for premium users, but Ezoic injects anchor, side
rail, interstitial and video ads by itself, outside React.

AdScripts is a server component. It reads the session and renders no
script for a premium user. A session error keeps the ads on.
@vercel

vercel Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
workout-cool-opqe Ready Ready Preview Sep 20, 2026 10:26am UTC

Request Review

@Snouzy
Snouzy merged commit 3e65987 into main Sep 20, 2026
5 checks passed

This branch was successfully deployed

1 active deployment
Preview — a72020a4 Deployed Sep 20, 2026 by vercel[bot]
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