{"id":10704,"date":"2026-05-19T05:29:48","date_gmt":"2026-05-18T21:29:48","guid":{"rendered":"https:\/\/aeosub.com\/headless-login-guard\/"},"modified":"2026-05-19T05:29:48","modified_gmt":"2026-05-18T21:29:48","slug":"headless-login-guard","status":"publish","type":"post","link":"https:\/\/aeosub.com\/zh\/headless-login-guard\/","title":{"rendered":"Headless Login Guard"},"content":{"rendered":"<div class=\"post-img\" style=\"margin-bottom: 25px\"><img decoding=\"async\" src=\"https:\/\/ps.w.org\/headless-login-guard\/assets\/banner-1544x500.png?rev=3536308\" alt=\"Headless Login Guard\" style=\"width: 100%;height: auto;border-radius: 12px\"><\/div>\n<div class=\"plugin-info-card\" style=\"border: 1px solid #e2e8f0;border-radius: 10px;overflow: hidden;margin-bottom: 30px;font-family: -apple-system, system-ui, sans-serif;background: #fff\">\n<table style=\"width: 100%;border-collapse: collapse;font-size: 14px\">\n<tr style=\"border-bottom: 1px solid #edf2f7\">\n<th style=\"padding: 15px 20px;text-align: left;width: 35%;color: #4a5568;background: #fcfcfc\"><img decoding=\"async\" src=\"https:\/\/ps.w.org\/headless-login-guard\/assets\/icon-256x256.png?rev=3536307\" style=\"width: 40px;height: 40px;border-radius: 6px;margin-right: 12px;vertical-align: middle\"> Developer<\/th>\n<td style=\"padding: 15px 20px;font-weight: 500\"><a href=\"https:\/\/profiles.wordpress.org\/andrew40\/\" target=\"_blank\" rel=\"noopener\">Andrew Wilkinson<\/a><\/td>\n<\/tr>\n<tr style=\"border-bottom: 1px solid #edf2f7\">\n<th style=\"padding: 12px 20px;text-align: left;color: #4a5568;background: #fcfcfc\">Version<\/th>\n<td style=\"padding: 12px 20px\">v1.0.1<\/td>\n<\/tr>\n<tr style=\"border-bottom: 1px solid #edf2f7\">\n<th style=\"padding: 12px 20px;text-align: left;color: #4a5568;background: #fcfcfc\">Active Installs<\/th>\n<td style=\"padding: 12px 20px\">0 +<\/td>\n<\/tr>\n<tr style=\"border-bottom: 1px solid #edf2f7\">\n<th style=\"padding: 12px 20px;text-align: left;color: #4a5568;background: #fcfcfc\">Requires \/ Tested<\/th>\n<td style=\"padding: 12px 20px\">6.0 \/ 6.9.4<\/td>\n<\/tr>\n<tr style=\"border-bottom: 1px solid #edf2f7\">\n<th style=\"padding: 12px 20px;text-align: left;color: #4a5568;background: #fcfcfc\">Last Updated<\/th>\n<td style=\"padding: 12px 20px\">2026-05-18 8:47pm GMT<\/td>\n<\/tr>\n<tr>\n<th style=\"padding: 12px 20px;text-align: left;color: #4a5568;background: #fcfcfc\">Official Link<\/th>\n<td style=\"padding: 12px 20px\"><a href=\"https:\/\/wordpress.org\/plugins\/headless-login-guard\/\" target=\"_blank\" style=\"text-decoration: none;color: #4a3bca;font-weight: bold\" rel=\"noopener\">View Details \u2192<\/a><\/td>\n<\/tr>\n<\/table><\/div>\n<div class=\"plugin-short-desc\" style=\"margin: 20px 0;padding: 12px 15px;background: #f9fafb;border-left: 4px solid #4a3bca;border-radius: 6px;font-style: italic;color: #4a5568\">Forces login for backend access in headless WordPress setups while allowing GraphQL\/REST API endpoints and essential paths.<\/div>\n<p>A lightweight plugin that <strong>forces login for backend access<\/strong> in a headless WordPress setup. Keeps your WordPress dashboard private while allowing your front end (e.g. Astro, Next.js) to pull content via GraphQL\/REST.<\/p>\n<h4>What it does<\/h4>\n<ul>\n<li>Requires authentication for <code>\/wp-admin\/<\/code> and other backend pages<\/li>\n<li>Always allows the login page to avoid redirect loops<\/li>\n<li>Leaves key endpoints open for headless use:\n<ul>\n<li><code>\/wp-json\/<\/code> (REST API)<\/li>\n<li><code>\/graphql<\/code> (WPGraphQL)<\/li>\n<li><code>\/wp-admin\/admin-ajax.php<\/code> (AJAX)<\/li>\n<li><code>\/wp-cron.php<\/code> (cron)<\/li>\n<li><code>\/robots.txt<\/code><\/li>\n<li><code>\/sitemap*.xml<\/code> (sitemaps and indexes)<\/li>\n<li><code>\/wp-content\/uploads\/*<\/code> (media)<\/li>\n<li><code>\/favicon.ico<\/code><\/li>\n<li><code>\/newrelic<\/code> (New Relic monitoring)<\/li>\n<\/ul>\n<\/li>\n<li>Logged-in users visiting the backend root get redirected to the dashboard<\/li>\n<li>Works with Bedrock layouts (handles root path vs <code>\/wp\/<\/code>)<\/li>\n<\/ul>\n<h4>Use case<\/h4>\n<ul>\n<li>WordPress is the content backend<\/li>\n<li>Public site is built with Astro\/Next.js\/etc<\/li>\n<li>Editors log in to WordPress. Visitors never see the backend<\/li>\n<li>Front end builds and live pages can still query GraphQL\/REST without authentication<\/li>\n<\/ul>\n<h4>Customization<\/h4>\n<p>Developers can customize allowed endpoints using the <code>force_login_allowed_patterns<\/code> filter:<\/p>\n<pre><code>add_filter('force_login_allowed_patterns', function($patterns) {\n    $patterns[] = '#^\/healthz$#';           \/\/ custom health check\n    $patterns[] = '#^\/status$#';            \/\/ uptime checks\n    $patterns[] = '#^\/wp-json\/acf\/v3\/.*#';  \/\/ specific REST namespace\n    return $patterns;\n});\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>Forces login for backend access in headless WordPress setups while allowing GraphQL\/REST API endpoints and essential paths.<\/p>","protected":false},"author":1,"featured_media":9317,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[252],"tags":[1290,1291,1028,1085,664,555],"class_list":["post-10704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-trends","tag-graphql","tag-headless","tag-login","tag-rest-api","tag-security","tag-wordpress-plugin"],"_links":{"self":[{"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/posts\/10704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/comments?post=10704"}],"version-history":[{"count":0,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/posts\/10704\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/media\/9317"}],"wp:attachment":[{"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/media?parent=10704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/categories?post=10704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aeosub.com\/zh\/wp-json\/wp\/v2\/tags?post=10704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}