← BlogFix prompt3 min readUpdated 2026-08-03

Prompt: actually protect your admin pages

Turns cosmetic role checks into enforcement that survives someone typing the URL directly.


Hiding a link is not access control. If the only thing between a stranger and /admin is that you did not put it in the menu, the page is public — URLs leak through history, analytics and simple guessing.

Copy this into Cursor, Claude Code, Lovable or your builder
Make access control on my protected routes real rather than cosmetic.

1. List every route that should be restricted, and show me exactly where
   each is enforced. Any route protected only by a conditional render or a
   client-side redirect is not protected — mark it clearly.
2. Enforce on the server: middleware or a check at the top of each route
   handler that verifies the session and the user's role before returning
   anything.
3. Enforce at the data layer too, so the rule holds even if a route is
   missed — Row Level Security policies that check role and ownership.
4. Store roles in a table the user cannot write to. If the role lives in
   client-editable user metadata, an ordinary user can promote themselves;
   fix that before anything else.
5. Return 404 rather than 403 for admin routes, so their existence is not
   confirmed to someone probing.

Show me a table: route, what enforces it now, and what an anonymous
visitor and a normal signed-in user each receive.

What your AI should do with it

  • Server-side checks, not just component-level conditionals.
  • A second layer at the database, so one missed route is not fatal.
  • Roles stored where the user cannot edit them.

How to check it worked

Try to reach it as a stranger

  1. 1Open a private window so you are signed out.
  2. 2Go straight to /admin, /dashboard, /settings, /users.
  3. 3You should get a login screen or a 404 — never a rendered page.
  4. 4Sign in as a normal non-admin user and repeat.

This is one check out of 40+

Paste your site address and we run the whole list from the outside — leaked keys, open databases, unprotected pages — then hand you one prompt that fixes what we find. Free, about 30 seconds, no signup.

Check my site — free