front pagerelevant informationThe integrity and crossorigin fields in the link tag
The integrity and crossorigin fields in the link tag
Table of Contents

crossorigin:

This enumeration attribute specifies whether CORS must be used when loading related images. The possible values ​​include the following two:

  • anonymous: A cross-origin request is made (i.e., it contains an Origin: HTTP header). However, no authentication information is sent (i.e., no cookies, X.509 certificates, and HTTP basic authentication information are sent). If the server does not provide the origin credentials (the Access-Control-Allow-Origin: HTTP header is not set), the image will be contaminated and restricted from use.

  • use-credentials: will initiate a cross-origin request (i.e. including the Origin: HTTP header) with authentication information (sending cookies, X.509 certificates and HTTP basic authentication information). If the server does not give the origin credentials (does not set the Access-Control-Allow-Origin: HTTP header), the image will be tainted and restricted.

  • When this attribute is not set, the resource will not use CORS loading (that is, will not send the Origin: HTTP header), which will prevent it from being used in the element. If an invalid value is set, it is treated as anonymous.

integrity

Subresource Integrity (SRI) is a security feature that enables browsers to verify that files they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched file must match.

Translation:

Subresource Integrity (SRI) is a security feature that lets a browser verify that files it fetches (e.g. from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched file must match.

Example:

<link rel="stylesheet" href="/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">  
<script src="/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
Software application: front-end template download; development and design; SEO optimization; offline web browsing. Note: This software is not a hacking program and cannot download background data!
Disclaimer: The services are used for personal learning, research or appreciation, as well as other non-commercial or non-profit purposes, but at the same time should comply with the provisions of copyright law and other relevant laws, and must not infringe the legitimate rights of this website and related rights holders. The risks arising from the use of this site's tools have nothing to do with this software.
Copyright © 2019-2024 Rabbit Software All Rights Reserved Guangdong ICP No. 19111427-2
Tutorial Information User Manual Website topics