Repository navigation
Replies: 2 comments 1 reply
|
we dont have this yet. needs to be added |
|
@schiller-manuel's "needs to be added" was right in February. It has since landed as // src/server.ts (picked up automatically, replaces the default server entry)
import { createStartHandler, defaultStreamHandler } from '@tanstack/react-start/server'
import { createServerEntry } from '@tanstack/react-start/server-entry'
const fetch = createStartHandler({
handler: defaultStreamHandler,
transformAssets: {
prefix: process.env.CDN_ORIGIN || '', // '' leaves URLs unchanged and only adds the attribute
crossOrigin: 'anonymous', // or { script: 'anonymous' } to leave stylesheets alone
},
})
export default createServerEntry({ fetch })This sets There is also About the Next.js comparison. Next's chunks are classic scripts, and for classic scripts The attribute does change behaviour in two cases: stylesheets (it switches them from no-cors to cors) and Rsbuild CDN checklist. This comes from a Next.js app at work, where adding
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I'm looking for the correct way to add a crossOrigin attribute to all the <script> tags generated by my TanStack Start application.
When serving JS assets from a different origin (e.g., a CDN), browsers mask the details of any errors thrown from those scripts for security reasons. This results in a generic and unhelpful "Script error." message.
The standard solution is to add crossorigin="anonymous" to the script tags. This allows the browser to expose the full error details, restoring essential debugging and error handling capabilities.
In Next.js, this is handled via a simple global configuration:
I'm trying to achieve the same result in TanStack Start.
Could you please advise on the recommended way to achieve this? Is there an existing mechanism I've missed, or would this be considered a feature request?
All reactions