Request: credentials property
Request: credentials property - Web APIs | MDN
The credentials
read-only property of the Request
interface reflects the value given to the Request()
constructor in the credentials
option. It determines whether or not the browser sends credentials with the request, as well as whether any Set-Cookie
response headers are respected.
Credentials are cookies, TLS client certificates, or authentication headers containing a username and password.
See Including credentials for more details.
Value
A string with one of the following values:
omit
-
Never send credentials in the request or include credentials in the response.
same-origin
-
Only send and include credentials for same-origin requests.
include
-
Always include credentials, even for cross-origin requests.
Examples
In the following snippet, we create a new request using the Request()
constructor (for an image file in the same directory as the script), then save the request credentials in a variable:
1 2 | const request = new Request( "flowers.jpg" ); const request = request.request; // returns "same-origin" by default |
调用的例子
import { API_BASE, credentials } from '../routes';
const result = await fetch(url, {
method,
credentials: credentials,
headers: { ...headers },
...data,
}).
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-10-30 【佣兵战纪】初始队通关PVE全攻略&培养建议
2018-10-30 AjaxControlToolkit没有通过WebResource.axd加载css导致ajaxToolkit:TabPanel无法显示正确的样式
2017-10-30 RSA in .net and dotnet core
2017-10-30 单点登录
2015-10-30 git svn rebase出现了checksum mismatch的错误
2014-10-30 8.2.2继承 第8章 面向对象编程简介
2014-10-30 单例模式和静态类的区别