html.crossorigin
- Type:
boolean | 'anonymous' | 'use-credentials' - Default:
false
Set the crossorigin attribute of the <script> and <link rel="stylesheet"> tags.
- If
trueis passed, it will automatically be set tocrossorigin="anonymous". - If
falseis passed, it will not set thecrossoriginattr.
Example
rsbuild.config.ts
After compilation, the <script> tag in HTML becomes:
The <link rel="stylesheet"> tag becomes:
Tip
When this option is enabled, Rsbuild adds the crossorigin attribute to tags that load script and stylesheet files, regardless of whether the resources are from the same origin. If a tag already has this attribute, its value is preserved.
Optional values
crossorigin can be set to the following values:
anonymous: Request uses CORS headers and credentials flag is set to 'same-origin'. There is no exchange of user credentials via cookies, client-side SSL certificates or HTTP authentication, unless destination is the same origin.use-credentials: Request uses CORS headers, credentials flag is set to 'include' and user credentials are always included.

