fix(request): cross domain api issue (#2026)

Fix the issue when NCMapi is not under the same domain
as the one frontend uses. The original method using
Vercel to proxy requests may cause latency under
some circumstances.
This commit is contained in:
Holger 2023-04-08 23:13:28 +08:00 committed by GitHub
parent 8a50337854
commit 65f5df8a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -23,7 +23,11 @@ const service = axios.create({
service.interceptors.request.use(function (config) {
if (!config.params) config.params = {};
if (baseURL.length) {
if (baseURL[0] !== '/' && !process.env.IS_ELECTRON) {
if (
baseURL[0] !== '/' &&
!process.env.IS_ELECTRON &&
getCookie('MUSIC_U') !== null
) {
config.params.cookie = `MUSIC_U=${getCookie('MUSIC_U')};`;
}
} else {

View File

@ -275,7 +275,7 @@ export default {
clearInterval(this.qrCodeCheckInterval);
this.qrCodeInformation = '登录成功,请稍等...';
result.code = 200;
result.cookie = result.cookie.replace('HTTPOnly', '');
result.cookie = result.cookie.replaceAll(' HTTPOnly', '');
this.handleLoginResponse(result);
}
});