Replies: 7 comments 8 replies
-
No answers what so ever on this? |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in an answer here. |
Beta Was this translation helpful? Give feedback.
-
I've created an issue related to it #9719 |
Beta Was this translation helpful? Give feedback.
-
Hi @afoninv What is the "html-transform" plugin you are using? Do you have any example in oder to try to do the same with Vite? Please. |
Beta Was this translation helpful? Give feedback.
-
We ended up doing this: in vite.config.ts
All bundled script tags now get the placeholder |
Beta Was this translation helpful? Give feedback.
-
Throwing a random regex STRING into the final rendering of a page is NOT what a strict CSP does. The next time that page is rendered the STRING needs to be checked - to see if it matches on a per PHP session basis. Thumbs down VITE. Thumbs down LiveWire. Thumbs down Laravel for wasting so many new coders time on trying to fix something included by default in new Laravel project installs. Actually, two thumbs down Laravel - for not being clear a strict CSP - CAN NOT BE DONE! (using Vite) Be honest CLEAR Laravel. : ( |
Beta Was this translation helpful? Give feedback.
-
I haven't found documentation or discussions surrounding this and the last comment here was pretty recent so I thought I'd point out what worked for me, which I'm sure there's even a better way to do it but since I've got a SPA it solved my use case: I added this at the top of my main blade: <?php Vite::useScriptTagAttributes(['onerror' => 'handleError(error)']); ?> Now I know there's some internal logic for nonces so it might not solve the nonce issue, but "how to pass attributes" – worked for me in dev and prod. |
Beta Was this translation helpful? Give feedback.
-
In a fairly common setup, I have a single entry point for JS code in html:
The idea is to use nonces for strict CSP , substituting value of
NONCE_PLACEHOLDER
each time a server (nginx in my case) servesindex.html
.However, generated html file loses
nonce
attribute in relevant<script>
and<link>
tags:Desired result is:
Is there a regular way to achieve that with Vite?
(Right now I have to resort to injecting nonce attribute with html-transform plugin. Plugin has to know about implementation details of what do tags generated by Vite look like. This is fragile so I'm looking for a more proper way)
Beta Was this translation helpful? Give feedback.
All reactions