mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
20 lines
1.3 KiB
Plaintext
20 lines
1.3 KiB
Plaintext
---
|
|
title: crossOrigin
|
|
description: Use the `crossOrigin` option to add a crossOrigin tag on the `script` tags generated by `next/script`.
|
|
---
|
|
|
|
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
|
|
|
|
Use the `crossOrigin` option to add a [`crossOrigin` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) in all `<script>` tags generated by the <AppOnly>[`next/script`](/docs/app/building-your-application/optimizing/scripts) component</AppOnly> <PagesOnly>[`next/script`](/docs/pages/building-your-application/optimizing/scripts) and [`next/head`](/docs/pages/api-reference/components/head)components</PagesOnly>, and define how cross-origin requests should be handled.
|
|
|
|
```js filename="next.config.js"
|
|
module.exports = {
|
|
crossOrigin: 'anonymous',
|
|
}
|
|
```
|
|
|
|
## Options
|
|
|
|
- `'anonymous'`: Adds [`crossOrigin="anonymous"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin#anonymous) attribute.
|
|
- `'use-credentials'`: Adds [`crossOrigin="use-credentials"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin#use-credentials).
|