分享一个适用于iOS surge的模块+脚本
解决:Claude 账号被封禁,导致APP重复报错
Something went wrong* Try sending your message again
claude.sgmodule
# ==================== Claude Force Logout - 升级版 ====================
# 必须开启 MITM + 信任证书
[MITM]
hostname = claude.ai, api.anthropic.com, *.claude.ai
[Script]
claude-force-401 = type=http-response, pattern=^https?://(claude\.ai|api\.anthropic\.com), requires-response-body=false, script-path=[脚本路径], timeout=15, debug=true
# 备用 Rewrite(如果 JS 不稳定)
[URL Rewrite]
^https?://claude\.ai/api/account\? https://claude.ai/api/account 301
[Response Rewrite]
# 可选辅助
claude-401-helper = type=response, pattern=^https?://claude\.ai/api/account, status=401, body={"type":"error","error":{"type":"authentication_error","message":"Session invalid, please login again."}}
脚本文件
// Claude iOS 强制清除 Session - 升级版
// 针对多个认证路径 + 更强清 cookie
if ($request.url.includes('/api/account') ||
$request.url.includes('/api/auth') ||
$request.url.includes('/api/users') ||
$request.url.includes('/v1/')) {
let body = {
"type": "error",
"error": {
"type": "authentication_error",
"message": "Session invalid, please login again."
}
};
let headers = $response.headers || {};
// 强力清除 cookies
headers\['Set-Cookie'\] = \[
'sessionKey=; Domain=claude.ai; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Secure; SameSite=None',
'routingHint=; Domain=claude.ai; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Secure; SameSite=None',
'\__cf_bm=; Domain=claude.ai; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT',
'\_cfuvid=; Domain=claude.ai; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT'
\].join(', ');
$done({
status: 401,
headers: headers,
body: JSON.stringify(body)
});
} else {
$done({});
}
启用对应模块+脚本后,进入一次APP,然后杀掉后台即可