diff --git a/README.md b/README.md index 49c61a8f..bb20f2ba 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ sub.store = 127.0.0.1 Sub-Store also supports a configurable browser CORS allowlist for the backend API. This does not change the module rewrite domain, but it limits which browser origins can read API responses through CORS. -- Node/server deployments use `SUB_STORE_CORS_ALLOWED_ORIGINS`; the default is `https://sub-store.vercel.app,http://substore.stash,https://substore.stash`. -- Proxy App modules use the `cors` module argument; the default is `https://sub-store.vercel.app,http://substore.stash,https://substore.stash`. +- Node/server deployments use `SUB_STORE_CORS_ALLOWED_ORIGINS`; the default is `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org`. +- Proxy App modules use the `cors` module argument; the default is `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org`. - Multiple origins can be separated by commas. Origins are matched exactly by scheme, host, and port. Set the value to `*` only when you accept the risk of any website reading the local backend through browser CORS. ## Node push notifications diff --git a/backend/package.json b/backend/package.json index 0263a1c9..abd7d785 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.44.8", + "version": "2.44.9", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "packageManager": "pnpm@11.0.9", diff --git a/backend/src/test/config/cors-module-config.spec.js b/backend/src/test/config/cors-module-config.spec.js index 18f50031..59df675f 100644 --- a/backend/src/test/config/cors-module-config.spec.js +++ b/backend/src/test/config/cors-module-config.spec.js @@ -7,7 +7,7 @@ import { describe, it } from 'mocha'; import { load } from '@/utils/yaml'; const DEFAULT_ORIGINS = - 'https://sub-store.vercel.app,http://substore.stash,https://substore.stash'; + 'https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org'; describe('module CORS allowlist config', function () { it('adds the default CORS argument to Surge modules', function () { diff --git a/backend/src/test/vendor/express-cors.spec.js b/backend/src/test/vendor/express-cors.spec.js index 66a5b9a2..edc7c6f2 100644 --- a/backend/src/test/vendor/express-cors.spec.js +++ b/backend/src/test/vendor/express-cors.spec.js @@ -39,7 +39,7 @@ describe('express CORS allowlist adapter', function () { expect( logs.filter((log) => log.startsWith('[CORS]')), ).to.deep.equal([ - '[CORS] SUB_STORE_CORS_ALLOWED_ORIGINS is not set; using default allowed origins: https://sub-store.vercel.app,http://substore.stash,https://substore.stash', + '[CORS] SUB_STORE_CORS_ALLOWED_ORIGINS is not set; using default allowed origins: https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org', ]); }, ); @@ -86,7 +86,7 @@ describe('express CORS allowlist adapter', function () { expect( logs.filter((log) => log.startsWith('[CORS]')), ).to.deep.equal([ - '[CORS] allowed origins: https://sub-store.vercel.app,http://substore.stash,https://substore.stash,http://localhost:,http://127.0.0.1: (default:node)', + '[CORS] allowed origins: https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org,http://localhost:,http://127.0.0.1: (default:node)', ]); }, 'custom', diff --git a/backend/src/utils/cors.js b/backend/src/utils/cors.js index df4fec84..1cdd1675 100644 --- a/backend/src/utils/cors.js +++ b/backend/src/utils/cors.js @@ -2,7 +2,7 @@ export const NODE_CORS_ALLOWED_ORIGINS_ENV = 'SUB_STORE_CORS_ALLOWED_ORIGINS'; export const NON_NODE_CORS_DEFAULT = - 'https://sub-store.vercel.app,http://substore.stash,https://substore.stash'; + 'https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org'; export const NODE_CORS_DEFAULT = NON_NODE_CORS_DEFAULT; export const CORS_ARGUMENT_KEY = 'cors'; diff --git a/config/Egern.yaml b/config/Egern.yaml index 88939269..b4ed808a 100644 --- a/config/Egern.yaml +++ b/config/Egern.yaml @@ -14,14 +14,14 @@ compat_arguments: sync_success_notify: true produce_sub: "sub1,sub2" produce_col: "col1,col2" - cors: "https://sub-store.vercel.app,http://substore.stash,https://substore.stash" + cors: "https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org" compat_arguments_desc: | 脚本超时(Egern 有问题, 不支持自定义, 本文件中固定为 900 秒) 1️⃣ cors 允许浏览器跨域访问 Sub-Store 后端的 origin. - 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash. + 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org. 多个用 , 连接. 设为 * 可恢复旧的任意来源访问行为, 存在钓鱼网站读取配置的风险 @@ -95,7 +95,7 @@ scriptings: _compat.$argument: "cors={{{cors}}}" - schedule: name: "{{{sync}}}" - disabled: {{{sync_disabled}}} + disabled: { { { sync_disabled } } } cron: "{{{cronexp}}}" script_url: https://github.com/sub-store-org/Sub-Store/releases/latest/download/cron-sync-artifacts.min.js timeout: 900 @@ -103,7 +103,7 @@ scriptings: _compat.$argument: "sync_success_notify={{{sync_success_notify}}}" - schedule: name: "{{{produce}}}" - disabled: {{{produce_disabled}}} + disabled: { { { produce_disabled } } } cron: "{{{produce_cronexp}}}" script_url: https://github.com/sub-store-org/Sub-Store/releases/latest/download/cron-sync-artifacts.min.js timeout: 900 diff --git a/config/Loon.plugin b/config/Loon.plugin index cba8807e..8b73b869 100644 --- a/config/Loon.plugin +++ b/config/Loon.plugin @@ -8,7 +8,7 @@ [Argument] cron=input, "55 23 * * *", tag=定时参数, desc=这里需要输入符合CRON表达式的参数 sync_success_notify=switch, true, tag=同步成功通知, desc=同步配置全部成功时是否发送完成通知 -cors=input, "https://sub-store.vercel.app,http://substore.stash,https://substore.stash", tag=CORS允许来源, desc=允许浏览器跨域访问 Sub-Store 后端的 origin. 多个用 , 连接. 设为 * 可恢复旧行为 +cors=input, "https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org", tag=CORS允许来源, desc=允许浏览器跨域访问 Sub-Store 后端的 origin. 多个用 , 连接. 设为 * 可恢复旧行为 [Rule] DOMAIN,sub-store.vercel.app,PROXY diff --git a/config/README.md b/config/README.md index b34f8f93..7b3b108d 100644 --- a/config/README.md +++ b/config/README.md @@ -16,13 +16,13 @@ https://xream.notion.site/Sub-Store-abe6a96944724dc6a36833d5c9ab7c87 Sub-Store 后端会根据请求的 `Origin` 判断浏览器跨域访问是否允许。允许值是 origin, 需要包含协议、域名和端口, 不包含路径。例如 `https://sub-store.vercel.app` 或 `http://127.0.0.1:8888`。 -Node/服务器/Docker/Android 版可以通过环境变量 `SUB_STORE_CORS_ALLOWED_ORIGINS` 设置, 默认值为 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash`。多个 origin 用 `,` 分隔, 例如: +Node/服务器/Docker/Android 版可以通过环境变量 `SUB_STORE_CORS_ALLOWED_ORIGINS` 设置, 默认值为 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org`。多个 origin 用 `,` 分隔, 例如: ```bash SUB_STORE_CORS_ALLOWED_ORIGINS=https://sub-store.vercel.app,http://127.0.0.1:8888 ``` -支持参数配置的 App 模块使用 `cors` 参数设置, 默认值为 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash`。如果需要使用本地前端 `http://127.0.0.1:8888?api=http://127.0.0.1:3001/123` 测试代理 App 后端, 需要把模块里的 `cors` 改成 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,http://127.0.0.1:8888`。设为 `*` 可恢复旧的任意来源访问行为, 但任意网站都可能通过浏览器 CORS 读取本机 Sub-Store 后端响应, 不建议长期使用。 +支持参数配置的 App 模块使用 `cors` 参数设置, 默认值为 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org`。如果需要使用本地前端 `http://127.0.0.1:8888?api=http://127.0.0.1:3001/123` 测试代理 App 后端, 需要把模块里的 `cors` 改成 `https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org,http://127.0.0.1:8888`。设为 `*` 可恢复旧的任意来源访问行为, 但任意网站都可能通过浏览器 CORS 读取本机 Sub-Store 后端响应, 不建议长期使用。 ### 1. Loon diff --git a/config/Surge-Beta.sgmodule b/config/Surge-Beta.sgmodule index 45fe3846..5a25b16c 100644 --- a/config/Surge-Beta.sgmodule +++ b/config/Surge-Beta.sgmodule @@ -1,8 +1,8 @@ #!name=Sub-Store(β) #!desc=支持 Surge 正式版的参数设置功能. 测落地功能 ability: http-client-policy, 同步配置的定时 cronexp: 55 23 * * * #!category=订阅管理 -#!arguments=ability:http-client-policy,cronexp:55 23 * * *,sync:"Sub-Store Sync",timeout:900,engine:auto,produce:"# Sub-Store Produce",produce_cronexp:50 */6 * * *,sync_success_notify:true,produce_sub:"sub1,sub2",produce_col:"col1,col2",max_size:-1,cors:"https://sub-store.vercel.app,http://substore.stash,https://substore.stash" -#!arguments-desc=\n1️⃣ ability\n\n默认已开启测落地能力\n需要配合脚本操作\n如 https://raw.githubusercontent.com/Keywos/rule/main/cname.js\n填写任意其他值关闭\n\n2️⃣ cronexp\n\n同步配置定时任务\n默认为每天 23 点 55 分\n\n定时任务指定时将订阅/文件上传到私有 Gist. 在前端, 叫做 '同步' 或 '同步配置'\n\n3️⃣ sync\n\n自定义定时任务名\n便于在脚本编辑器中选择\n若设为 # 可取消定时任务\n\n4️⃣ timeout\n\n脚本超时, 单位为秒\n\n5️⃣ engine\n\n默认为自动使用 webview 引擎, 可设为指定 jsc, 但 jsc 容易爆内存\n\n6️⃣ produce\n\n自定义处理订阅的定时任务名\n一般用于定时处理耗时较长的订阅, 以更新缓存\n这样 Surge 中拉取的时候就能用到缓存, 不至于总是超时\n若设为 # 可取消此定时任务\n默认不开启\n\n7️⃣ produce_cronexp\n\n配置处理订阅的定时任务\n\n默认为每 6 小时\n\n8️⃣ sync_success_notify\n\n同步配置全部成功时是否发送完成通知\n默认为 true, 填 false/0/no/off 可关闭\n\n9️⃣ produce_sub\n\n自定义需定时处理的单条订阅名\n多个用 , 连接\n\n🔟 produce_col\n\n自定义需定时处理的组合订阅名\n多个用 , 连接\n\n1️⃣1️⃣ cors\n\n允许浏览器跨域访问 Sub-Store 后端的 origin. 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash. 多个用 , 连接. 设为 * 可恢复旧的任意来源访问行为, 存在钓鱼网站读取配置的风险\n\n⚠️ 注意: 是 名称(name) 不是 显示名称(displayName)\n如果名称需要编码, 请编码后再用 , 连接\n顺序: 并发执行单条订阅, 然后并发执行组合订阅 +#!arguments=ability:http-client-policy,cronexp:55 23 * * *,sync:"Sub-Store Sync",timeout:900,engine:auto,produce:"# Sub-Store Produce",produce_cronexp:50 */6 * * *,sync_success_notify:true,produce_sub:"sub1,sub2",produce_col:"col1,col2",max_size:-1,cors:"https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org" +#!arguments-desc=\n1️⃣ ability\n\n默认已开启测落地能力\n需要配合脚本操作\n如 https://raw.githubusercontent.com/Keywos/rule/main/cname.js\n填写任意其他值关闭\n\n2️⃣ cronexp\n\n同步配置定时任务\n默认为每天 23 点 55 分\n\n定时任务指定时将订阅/文件上传到私有 Gist. 在前端, 叫做 '同步' 或 '同步配置'\n\n3️⃣ sync\n\n自定义定时任务名\n便于在脚本编辑器中选择\n若设为 # 可取消定时任务\n\n4️⃣ timeout\n\n脚本超时, 单位为秒\n\n5️⃣ engine\n\n默认为自动使用 webview 引擎, 可设为指定 jsc, 但 jsc 容易爆内存\n\n6️⃣ produce\n\n自定义处理订阅的定时任务名\n一般用于定时处理耗时较长的订阅, 以更新缓存\n这样 Surge 中拉取的时候就能用到缓存, 不至于总是超时\n若设为 # 可取消此定时任务\n默认不开启\n\n7️⃣ produce_cronexp\n\n配置处理订阅的定时任务\n\n默认为每 6 小时\n\n8️⃣ sync_success_notify\n\n同步配置全部成功时是否发送完成通知\n默认为 true, 填 false/0/no/off 可关闭\n\n9️⃣ produce_sub\n\n自定义需定时处理的单条订阅名\n多个用 , 连接\n\n🔟 produce_col\n\n自定义需定时处理的组合订阅名\n多个用 , 连接\n\n1️⃣1️⃣ cors\n\n允许浏览器跨域访问 Sub-Store 后端的 origin. 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org. 多个用 , 连接. 设为 * 可恢复旧的任意来源访问行为, 存在钓鱼网站读取配置的风险\n\n⚠️ 注意: 是 名称(name) 不是 显示名称(displayName)\n如果名称需要编码, 请编码后再用 , 连接\n顺序: 并发执行单条订阅, 然后并发执行组合订阅 [MITM] hostname = %APPEND% sub.store diff --git a/config/Surge.sgmodule b/config/Surge.sgmodule index 8628f2d5..d839a593 100644 --- a/config/Surge.sgmodule +++ b/config/Surge.sgmodule @@ -1,8 +1,8 @@ #!name=Sub-Store #!desc=支持 Surge 正式版的参数设置功能. 测落地功能 ability: http-client-policy, 同步配置的定时 cronexp: 55 23 * * * #!category=订阅管理 -#!arguments=ability:http-client-policy,cronexp:55 23 * * *,sync:"Sub-Store Sync",timeout:900,engine:auto,produce:"# Sub-Store Produce",produce_cronexp:50 */6 * * *,sync_success_notify:true,produce_sub:"sub1,sub2",produce_col:"col1,col2",max_size:-1,cors:"https://sub-store.vercel.app,http://substore.stash,https://substore.stash" -#!arguments-desc=\n1️⃣ ability\n\n默认已开启测落地能力\n需要配合脚本操作\n如 https://raw.githubusercontent.com/Keywos/rule/main/cname.js\n填写任意其他值关闭\n\n2️⃣ cronexp\n\n同步配置定时任务\n默认为每天 23 点 55 分\n\n定时任务指定时将订阅/文件上传到私有 Gist. 在前端, 叫做 '同步' 或 '同步配置'\n\n3️⃣ sync\n\n自定义定时任务名\n便于在脚本编辑器中选择\n若设为 # 可取消定时任务\n\n4️⃣ timeout\n\n脚本超时, 单位为秒\n\n5️⃣ engine\n\n默认为自动使用 webview 引擎, 可设为指定 jsc, 但 jsc 容易爆内存\n\n6️⃣ produce\n\n自定义处理订阅的定时任务名\n一般用于定时处理耗时较长的订阅, 以更新缓存\n这样 Surge 中拉取的时候就能用到缓存, 不至于总是超时\n若设为 # 可取消此定时任务\n默认不开启\n\n7️⃣ produce_cronexp\n\n配置处理订阅的定时任务\n\n默认为每 6 小时\n\n8️⃣ sync_success_notify\n\n同步配置全部成功时是否发送完成通知\n默认为 true, 填 false/0/no/off 可关闭\n\n9️⃣ produce_sub\n\n自定义需定时处理的单条订阅名\n多个用 , 连接\n\n🔟 produce_col\n\n自定义需定时处理的组合订阅名\n多个用 , 连接\n\n1️⃣1️⃣ cors\n\n允许浏览器跨域访问 Sub-Store 后端的 origin. 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash. 多个用 , 连接. 设为 * 可恢复旧的任意来源访问行为, 存在钓鱼网站读取配置的风险\n\n⚠️ 注意: 是 名称(name) 不是 显示名称(displayName)\n如果名称需要编码, 请编码后再用 , 连接\n顺序: 并发执行单条订阅, 然后并发执行组合订阅 +#!arguments=ability:http-client-policy,cronexp:55 23 * * *,sync:"Sub-Store Sync",timeout:900,engine:auto,produce:"# Sub-Store Produce",produce_cronexp:50 */6 * * *,sync_success_notify:true,produce_sub:"sub1,sub2",produce_col:"col1,col2",max_size:-1,cors:"https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org" +#!arguments-desc=\n1️⃣ ability\n\n默认已开启测落地能力\n需要配合脚本操作\n如 https://raw.githubusercontent.com/Keywos/rule/main/cname.js\n填写任意其他值关闭\n\n2️⃣ cronexp\n\n同步配置定时任务\n默认为每天 23 点 55 分\n\n定时任务指定时将订阅/文件上传到私有 Gist. 在前端, 叫做 '同步' 或 '同步配置'\n\n3️⃣ sync\n\n自定义定时任务名\n便于在脚本编辑器中选择\n若设为 # 可取消定时任务\n\n4️⃣ timeout\n\n脚本超时, 单位为秒\n\n5️⃣ engine\n\n默认为自动使用 webview 引擎, 可设为指定 jsc, 但 jsc 容易爆内存\n\n6️⃣ produce\n\n自定义处理订阅的定时任务名\n一般用于定时处理耗时较长的订阅, 以更新缓存\n这样 Surge 中拉取的时候就能用到缓存, 不至于总是超时\n若设为 # 可取消此定时任务\n默认不开启\n\n7️⃣ produce_cronexp\n\n配置处理订阅的定时任务\n\n默认为每 6 小时\n\n8️⃣ sync_success_notify\n\n同步配置全部成功时是否发送完成通知\n默认为 true, 填 false/0/no/off 可关闭\n\n9️⃣ produce_sub\n\n自定义需定时处理的单条订阅名\n多个用 , 连接\n\n🔟 produce_col\n\n自定义需定时处理的组合订阅名\n多个用 , 连接\n\n1️⃣1️⃣ cors\n\n允许浏览器跨域访问 Sub-Store 后端的 origin. 默认为 https://sub-store.vercel.app,http://substore.stash,https://substore.stash,https://sub.xream.eu.org. 多个用 , 连接. 设为 * 可恢复旧的任意来源访问行为, 存在钓鱼网站读取配置的风险\n\n⚠️ 注意: 是 名称(name) 不是 显示名称(displayName)\n如果名称需要编码, 请编码后再用 , 连接\n顺序: 并发执行单条订阅, 然后并发执行组合订阅 [MITM] hostname = %APPEND% sub.store