Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(renderToPipeableStream): Allow passing crossorigin attribute on bootstrapScripts #25989

Closed
HenriqueLimas opened this issue Jan 12, 2023 · 5 comments · Fixed by #26844
Closed

Comments

@HenriqueLimas
Copy link
Contributor

When using window.onerror in the bootstrap script that is hosted in a CDN the error message will show "Script error." instead of a proper error message. This is because of the cross-origin script. To fix this issue a crossorigin="anonymous" attribute needs to be added in the script tag.

Currently, bootstrapScripts supports src and integrity as configurations, should it also supports a crossorigin property?

@ElmoJones3
Copy link

+1

@pixelhuh
Copy link

pixelhuh commented Mar 7, 2023

Right now, bootstrapScripts lacks flexibility because we can't set scripts attributes. My application needs custom data-attributes on the scripts for compatibility, but I can't set them, this is complicates development.

it would be cool to be able to do something like this:

const { pipe } = renderToPipeableStream(<Page someProp="dummy" />, {
    bootstrapScripts: [{
        src: './main.js',
        crossorigin: true,
        'data-foo': 'bar',
    }],
    onShellReady() {
        res.setHeader('content-type', 'text/html');
        pipe(res);
    },
});

With this result:

<script src="/main.js" async="" crossorigin data-foo="bar"></script>

@rerodrigues
Copy link

+1

@gaearon
Copy link
Collaborator

gaearon commented May 23, 2023

Would someone like to send a PR?

@HenriqueLimas
Copy link
Contributor Author

Sure, let me do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants