Unable to resolve apiKey and baseUrl variables - cc-switch
Quick fix
Use {{ apiKey }} or {{baseUrl}} in the custom usage query template and verify that isValid: false is treated as a failure.
Symptom
Section titled “Symptom”自定义模板-配置用量查询-自定义。无法正常解析apiKey和baseUrl。在我实际测试中,这两个变量按照示例代码添加双括号无法正常解析出变量。本来我以为是我代码写的有问题,经过我不断测试发现,他没有成功解析出这两个变量导致我的请求无法生效,现在只能写死url才能正常生效。我使用的是最新版软件。Custom template - Configure usage query - Custom. apiKey and baseUrl cannot be resolved correctly. In my testing, adding double braces to these two variables as shown in the example code did not resolve the variables correctly. I initially thought there was a problem with my code, but after repeated testing I found that these two variables were not resolved, causing my request not to take effect. Currently, it only works when I hard-code the url. I am using the latest version of the software.
In a Windows report for cc-switch 3.14.1, the custom usage query template did not replace `apiKey` and `baseUrl`, so requests did not take effect; the reporter could only hard-code the URL. The same report said that `isValid` set to `false` was still shown as a successful test, with two `undefined` values.
The maintainer stated that this was fixed locally: templates support `{{ apiKey }}`, `{{baseUrl}}`, and similar syntax, and `isValid: false` triggers failure. The closure notes say records in v3.15.0 / v3.16.0 cover the issue, but a later comment says it still reproduces on Windows with v3.16.0. The actual fix status for that version is therefore conflicting and should be verified locally. The maintainer identified clearing custom code when switching presets as a separate UI state persistence issue.
In the custom template under “Configure usage query”, reference variables using the verified syntax, such as `{{ apiKey }}` or `{{baseUrl}}`.
When testing the script, verify `isValid: false` as a failure result; the maintainer record says it should trigger failure rather than show a successful test.
If variables still do not resolve or a failure result still shows as successful, retain the version, system environment, reproduction steps, and relevant logs, then continue following the source discussion; existing reports conflict on whether v3.16.0 fully fixes the issue.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 2 real issues
(No FAQ yet)
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.