{"record":{"id":"029de87ebd7e0b99","repo":"fish2018/pansou","slug":"error-029de8","errorCode":null,"errorMessage":"请求来源不被允许","messagePattern":"请求来源不被允许","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/panyq/panyq.go","lineNumber":172,"sourceCode":"\t\t}\n\t\t\n\t\t// 检查referer是否在允许列表中\n\t\tallowed := false\n\t\tfor _, allowedReferer := range AllowedReferers {\n\t\t\tif strings.HasPrefix(referer, allowedReferer) {\n\t\t\t\tif DebugLog {\n\t\t\t\t\tfmt.Printf(\"panyq: 允许来自 %s 的请求\\n\", referer)\n\t\t\t\t}\n\t\t\t\tallowed = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t\n\t\tif !allowed {\n\t\t\tif DebugLog {\n\t\t\t\tfmt.Printf(\"panyq: 拒绝来自 %s 的请求\\n\", referer)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"请求来源不被允许\")\n\t\t}\n\t}\n\t\n\t// 使用新的异步搜索方法\n\tresult, err := p.AsyncSearchWithResult(keyword, p.doSearch, p.MainCacheKey, ext)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresults := result.Results\n\t\n\t// 如果搜索成功，缓存结果\n\tif err == nil && len(results) > 0 {\n\t\tsearchResultCacheLock.Lock()\n\t\tsearchResultCache[cacheKey] = results\n\t\tsearchResultCacheLock.Unlock()\n\t}\n\t\n\treturn results, err","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/panyq/panyq.go#L154-L190","documentation":"The panyq plugin's public Search enforces a referer allow-list when EnableRefererCheck is true. The caller-supplied ext[\"referer\"] value did not prefix-match any entry in AllowedReferers, so the request is rejected with \"请求来源不被允许\".","triggerScenarios":"Search(keyword, ext) called with ext containing a referer string that has no prefix match in AllowedReferers while EnableRefererCheck is enabled; or ext is missing the referer key (empty string) when the check is on.","commonSituations":"Frontend not sending Referer (browser privacy settings/Referrer-Policy stripping it); new deployment domain not added to AllowedReferers config; trailing-slash or http vs https mismatch defeating prefix match; caller simply not passing ext[\"referer\"].","solutions":["Add the caller's origin to the AllowedReferers configuration.","Ensure the frontend sends the Referer header and that no Referrer-Policy strips it (e.g. set referrerpolicy=\"no-referrer-when-downgrade\").","Verify prefix matching expectations: \"https://example.com\" won't match \"https://example.org\" and scheme must match exactly.","If referer is unavailable by design, either disable EnableRefererCheck or pass the referer explicitly in ext.","Enable DebugLog to see the exact rejected referer value."],"exampleFix":"// before\nresult, err := plugin.Search(keyword, nil) // no referer passed, check enabled -> rejected\n// after\nresult, err := plugin.Search(keyword, map[string]interface{}{\"referer\": \"https://your-allowed-origin.com\"})","handlingStrategy":"validation","validationCode":"// Go (caller): ensure you send an allowed referer before calling Search\nreferer := \"https://your-allowed-origin.com\"\nallowed := false\nfor _, a := range plugin.AllowedReferers {\n    if strings.HasPrefix(referer, a) {\n        allowed = true\n        break\n    }\n}\nif !allowed {\n    return nil, fmt.Errorf(\"referer %q not in AllowedReferers; fix config or header\", referer)\n}","typeGuard":null,"tryCatchPattern":"result, err := plugin.Search(keyword, ext)\nif err != nil && err.Error() == \"请求来源不被允许\" {\n    log.Printf(\"referer %v rejected; check AllowedReferers config and ext[\\\"referer\\\"]\", ext[\"referer\"])\n    return err\n}","preventionTips":["Keep AllowedReferers in sync with every deployment origin (including http/https and www variants).","Ensure the frontend actually sends Referer; avoid Referrer-Policy settings that strip it.","Always populate ext[\"referer\"] when the referer check is enabled.","Enable DebugLog during integration to see exactly what referer value arrives."],"tags":["security","referer","config","go"],"backgroundTag":"permission-denied","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}