Fix nomadro.live ads.txt always served (ignore zh cookie)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,16 @@
|
|||||||
# TikTok Promo Next.js + FastAPI, plus English WordPress via audience router.
|
# TikTok Promo Next.js + FastAPI, plus English WordPress via audience router.
|
||||||
# /api stays on the existing backend. HTML is split: zh → :3015, en/bots → :8089.
|
# /ads.txt always served from disk (never via zh Next.js route).
|
||||||
|
|
||||||
nomadro.live, www.nomadro.live {
|
nomadro.live, www.nomadro.live {
|
||||||
encode gzip
|
encode gzip
|
||||||
|
|
||||||
|
handle /ads.txt {
|
||||||
|
root * /var/www/nomadro-live-wp
|
||||||
|
header Content-Type "text/plain; charset=utf-8"
|
||||||
|
header X-Robots-Tag "noindex"
|
||||||
|
file_server
|
||||||
|
}
|
||||||
|
|
||||||
handle /api/* {
|
handle /api/* {
|
||||||
reverse_proxy 127.0.0.1:8015
|
reverse_proxy 127.0.0.1:8015
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ const BOT_RE =
|
|||||||
const WP_PATH_RE =
|
const WP_PATH_RE =
|
||||||
/^\/(wp-admin|wp-login\.php|wp-cron\.php|wp-comments-post\.php|xmlrpc\.php|wp-json|wp-content|wp-includes)(\/|$)/i;
|
/^\/(wp-admin|wp-login\.php|wp-cron\.php|wp-comments-post\.php|xmlrpc\.php|wp-json|wp-content|wp-includes)(\/|$)/i;
|
||||||
|
|
||||||
|
const ALWAYS_WP_RE = /^\/(ads\.txt|robots\.txt)(\/|$|\?)/i;
|
||||||
|
|
||||||
function getCookie(req, name) {
|
function getCookie(req, name) {
|
||||||
const raw = req.headers.cookie || "";
|
const raw = req.headers.cookie || "";
|
||||||
for (const p of raw.split(/;\s*/)) {
|
for (const p of raw.split(/;\s*/)) {
|
||||||
@@ -115,6 +117,7 @@ function resolveTarget(req) {
|
|||||||
const url = req.url || "/";
|
const url = req.url || "/";
|
||||||
const path = url.split("?")[0];
|
const path = url.split("?")[0];
|
||||||
|
|
||||||
|
if (ALWAYS_WP_RE.test(path) || path === "/ads.txt" || path === "/robots.txt") return WP;
|
||||||
if (WP_PATH_RE.test(path)) return WP;
|
if (WP_PATH_RE.test(path)) return WP;
|
||||||
if (isBot(req)) return WP;
|
if (isBot(req)) return WP;
|
||||||
if (url.includes("noscript=1")) return WP;
|
if (url.includes("noscript=1")) return WP;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ const BOT_RE =
|
|||||||
const WP_PATH_RE =
|
const WP_PATH_RE =
|
||||||
/^\/(wp-admin|wp-login\.php|wp-cron\.php|wp-comments-post\.php|xmlrpc\.php|wp-json|wp-content|wp-includes)(\/|$)/i;
|
/^\/(wp-admin|wp-login\.php|wp-cron\.php|wp-comments-post\.php|xmlrpc\.php|wp-json|wp-content|wp-includes)(\/|$)/i;
|
||||||
|
|
||||||
|
const ALWAYS_WP_RE = /^\/(ads\.txt|robots\.txt)(\/|$|\?)/i;
|
||||||
|
|
||||||
function getCookie(req, name) {
|
function getCookie(req, name) {
|
||||||
const raw = req.headers.cookie || "";
|
const raw = req.headers.cookie || "";
|
||||||
for (const p of raw.split(/;\s*/)) {
|
for (const p of raw.split(/;\s*/)) {
|
||||||
@@ -118,6 +120,7 @@ function resolveTarget(req) {
|
|||||||
const url = req.url || "/";
|
const url = req.url || "/";
|
||||||
const path = url.split("?")[0];
|
const path = url.split("?")[0];
|
||||||
|
|
||||||
|
if (ALWAYS_WP_RE.test(path) || path === "/ads.txt" || path === "/robots.txt") return WP;
|
||||||
if (WP_PATH_RE.test(path)) return WP;
|
if (WP_PATH_RE.test(path)) return WP;
|
||||||
if (isBot(req)) return WP;
|
if (isBot(req)) return WP;
|
||||||
if (url.includes("noscript=1")) return WP;
|
if (url.includes("noscript=1")) return WP;
|
||||||
|
|||||||
Reference in New Issue
Block a user