[PR #16] [MERGED] fix(push-group): 更改 origin 获取方式 #34

Closed
opened 2026-03-01 14:53:48 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/beilunyang/moepush/pull/16
Author: @wyf9
Created: 4/19/2025
Status: Merged
Merged: 4/20/2025
Merged by: @beilunyang

Base: mainHead: fix/push-group-origin


📝 Commits (1)

  • 9efc24b fix: change origin get method

📊 Changes

2 files changed (+18 additions, -14 deletions)

View changed files

📝 .gitignore (+3 -0)
📝 app/api/push-group/[id]/route.ts (+15 -14)

📄 Description

原本的 origin 获取方式是直接读取请求的 Origin
但如果请求中没有包含 Origin 请求头,就会导致获取到的 origin 为 null,产生如下错误:

[14:52:48 wyf9@SRserver ~]$ curl -X POST "https://push.siiway.top/api/push-group/***" -H "Content-Type: application/json" -d '{
      "message": "示例message值",
      "title": "示例title值"
}'
{"status":"success","message":"接口组 SiiWaySecureRS 处理完成","total":2,"successCount":0,"failedCount":2,"details":[{"endpoint":"discord-wyf9server-private-push","status":"failed","error":"Invalid URL: null/api/push/***"},{"endpoint":"dingtalk-siiway-siiwaysecure-bot","status":"failed","error":"Invalid URL: null/api/push/***"}]}

因此作下面的修改:

// 之前的方式
const url = `${request.headers.get('origin')}/api/push/${endpoint.id}`

// 现在的方式
const origin = new URL(request.url).origin
const url = `${origin}/api/push/${endpoint.id}`

第一次写 ts,有错误欢迎指正


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/beilunyang/moepush/pull/16 **Author:** [@wyf9](https://github.com/wyf9) **Created:** 4/19/2025 **Status:** ✅ Merged **Merged:** 4/20/2025 **Merged by:** [@beilunyang](https://github.com/beilunyang) **Base:** `main` ← **Head:** `fix/push-group-origin` --- ### 📝 Commits (1) - [`9efc24b`](https://github.com/beilunyang/moepush/commit/9efc24bafec8a61269e39fb98d43874001241ce8) fix: change origin get method ### 📊 Changes **2 files changed** (+18 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -0) 📝 `app/api/push-group/[id]/route.ts` (+15 -14) </details> ### 📄 Description 原本的 origin 获取方式是直接读取请求的 `Origin` 头 但如果请求中没有包含 `Origin` 请求头,就会导致获取到的 origin 为 `null`,产生如下错误: ```jsonc [14:52:48 wyf9@SRserver ~]$ curl -X POST "https://push.siiway.top/api/push-group/***" -H "Content-Type: application/json" -d '{ "message": "示例message值", "title": "示例title值" }' {"status":"success","message":"接口组 SiiWaySecureRS 处理完成","total":2,"successCount":0,"failedCount":2,"details":[{"endpoint":"discord-wyf9server-private-push","status":"failed","error":"Invalid URL: null/api/push/***"},{"endpoint":"dingtalk-siiway-siiwaysecure-bot","status":"failed","error":"Invalid URL: null/api/push/***"}]} ``` 因此作下面的修改: ```ts // 之前的方式 const url = `${request.headers.get('origin')}/api/push/${endpoint.id}` // 现在的方式 const origin = new URL(request.url).origin const url = `${origin}/api/push/${endpoint.id}` ``` > *第一次写 ts,有错误欢迎指正* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 14:53:48 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/moepush#34
No description provided.