Skip to content

Commit

Permalink
fix(request): cross domain api issue (#2026)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HolgerHuo authored Apr 8, 2023
1 parent 8a50337 commit 65f5df8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/views/loginAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down

0 comments on commit 65f5df8

Please sign in to comment.