Skip to content

Ajax headers 设置不生效 #533

@iUUCoder

Description

@iUUCoder

vConsole Version: 3.14

从 3.14 开始,vConsole 改用了 Proxy 来实现 XHR 代理,导致 XHR 请求 header 设置不生效。

示例代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vConsole issues demo</title>
    <script src="https://unpkg.com/vconsole@3.14.5/dist/vconsole.min.js"></script>
    <script>
        // VConsole will be exported to `window.VConsole` by default.
        var vConsole = new window.VConsole();
    </script>
    <script src="https://zeptojs.com/zepto.min.js"></script>
</head>
<body>
    <button id="send-button">发送请求</button>

    <script>
        $('#send-button').on('click', function () {
            $.ajax({
                url: 'http://localhost:3000',
                type: 'GET',
                headers: {
                    'demo-field': 'Hello World'
                },
                success: function (data) {
                    // dosomething
                }
            });
        });
    </script>
</body>
</html>

示例代码效果:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions