[PR #472] [MERGED] fix(getOnlineUrl): 修复网页端登录后获取url的CORS问题 #474

Closed
opened 2026-02-27 07:11:59 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/imsyy/SPlayer/pull/472
Author: @MoeFurina
Created: 9/24/2025
Status: Merged
Merged: 9/25/2025
Merged by: @imsyy

Base: devHead: dev


📝 Commits (1)

  • 883ef05 fix(getOnlineUrl): 修复网页端登录后获取url的CORS问题

📊 Changes

1 file changed (+3 additions, -2 deletions)

View changed files

📝 src/utils/player.ts (+3 -2)

📄 Description

为什么要修改这里?

简单来说,CORS(跨域资源共享)是浏览器的一种安全机制。它要求网站A想从网站B加载资源时,网站B的服务器必须明确表示“我允许网站A来拿我的资源”。如果服务器没有给出这个“许可”,浏览器就会拦截这个请求。

网易云音乐的音乐链接有个特点:

  • 未登录时获取的链接(通常是 m801 或 m701 开头的域名)是配置好了这个“许可”的。

  • 登录后获取的链接(通常是 m804 或 m704 开头的域名)反而没有配置这个“许可”。

这就导致了一个问题:当我们直接使用登录后的链接去请求音乐时,浏览器会因为安全规则(CORS)而阻止。

解决方案很简单:

既然未登录的链接有“许可”,而登录前后的链接只有域名不同,那我们只需要把登录后链接里的域名(m804/m704)替换成未登录的域名(m801/m701)就可以了。这样,我们就能绕过浏览器的CORS限制,正常播放音乐。


🔄 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/imsyy/SPlayer/pull/472 **Author:** [@MoeFurina](https://github.com/MoeFurina) **Created:** 9/24/2025 **Status:** ✅ Merged **Merged:** 9/25/2025 **Merged by:** [@imsyy](https://github.com/imsyy) **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (1) - [`883ef05`](https://github.com/imsyy/SPlayer/commit/883ef05ab42eb95c5f2efc9357060e1f009bd3cf) fix(getOnlineUrl): 修复网页端登录后获取url的CORS问题 ### 📊 Changes **1 file changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/utils/player.ts` (+3 -2) </details> ### 📄 Description ## 为什么要修改这里? 简单来说,CORS(跨域资源共享)是浏览器的一种安全机制。它要求网站A想从网站B加载资源时,网站B的服务器必须明确表示“我允许网站A来拿我的资源”。如果服务器没有给出这个“许可”,浏览器就会拦截这个请求。 ### 网易云音乐的音乐链接有个特点: - 未登录时获取的链接(通常是 m801 或 m701 开头的域名)是配置好了这个“许可”的。 - 登录后获取的链接(通常是 m804 或 m704 开头的域名)反而没有配置这个“许可”。 这就导致了一个问题:当我们直接使用登录后的链接去请求音乐时,浏览器会因为安全规则(CORS)而阻止。 ### 解决方案很简单: 既然未登录的链接有“许可”,而登录前后的链接只有域名不同,那我们只需要把登录后链接里的域名(m804/m704)替换成未登录的域名(m801/m701)就可以了。这样,我们就能绕过浏览器的CORS限制,正常播放音乐。 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:11:59 +03:00
Sign in to join this conversation.
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/SPlayer#474
No description provided.