How to replace embedded credentials in subresource

2019-05-23 00:55发布

I get this error in the console in my Ionic app:

[Deprecation] Subresource requests whose URLs contain embedded credentials (e.g. `https://user:pass@host/`) are deprecated, and will be blocked in M59, around June 2017.

The line of code is a URL for an ajax request:

  function dbUrl() {
        return unescape(encodeURIComponent("http://idname:idnamepasswd@mysite.com/pDB.json"));
  }

How can I fix this?

1条回答
放荡不羁爱自由
2楼-- · 2019-05-23 01:30

The five-parameter version of the XMLHttpRequest.open method allows you to specify the username and password.

xhr.open(method, url, async, username, password)

Here's the documentation and the spec.

查看更多
登录 后发表回答