-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
%sveltekit.nonce% not being replaced #47
Comments
I'm not exactly sure why this isn't being replaced. We're only using this as a workaround due to an issue with the eslint plugin for svelte. I'd raise an issue with kit about the nonce. |
I wonder if this ever worked? or maybe it only works in app.html |
Maybe something to do with this sveltejs/kit#7945 and this sveltejs/kit#8427 |
I actually think there is more we can do here on this issue. I believe, based on:
notice how only
templates: {
app: ({ head, body, assets, nonce, env }) => ${s(template)
.replace('%sveltekit.head%', '" + head + "')
.replace('%sveltekit.body%', '" + body + "')
.replace(/%sveltekit\.assets%/g, '" + assets + "')
.replace(/%sveltekit\.nonce%/g, '" + nonce + "')
.replace(
/%sveltekit\.env\.([^%]+)%/g,
(_match, capture) => `" + (env[${s(capture)}] ?? "") + "`
)},
error: ({ status, message }) => ${s(error_page)
.replace(/%sveltekit\.status%/g, '" + status + "')
.replace(/%sveltekit\.error\.message%/g, '" + message + "')}
}, I tried to search the kit codebase for other replacements/usages of my conclusion is that therefore, I think we should:
thoughts? @huntabyte |
aha, or is the idea that we use if so, that does sound like a bug in kit. sorry for the false alarm 🤦 I wonder if the created an issue in kit: |
actually, scratch that last comment. I learned in a conversation on discord that the conclusion I drew earlier was correct. it has never worked and it will never work to have so we are back to:
we could also look into hashes but that also complicates things when it comes to minimisation. overall, personally I think it makes sense to:
for the advanced mode, I think I prefer the first option which leads to more lines of code in I am happy to start working on some or all of these changes after your approval |
Once I get back from traveling this week I really want to take a good look at how we could best tackle this. Part of me doesn't want to ignore the fact that it doesn't get replaced, but at the same time I want adding mode-watcher to projects to remain as simple as possible. I think I'm leaning towards your approach of the advanced/vs basic usage, but will further investigate this weekend. |
yeah I think that sounds great! I do think that if we want to keep it simple we should just remove
👍 |
hey guys, just ran into this in a production app. Would you mind sharing a workaround until this gets fixed? Alternatively I could just implement different dark mode switching, but this package is pretty neat. thank you! |
Good day,
I don't know if it was something that was noticed, but it seems like the nonce isn't being replaced when added dynamically with svelte:head.
I was taking inspiration on your project for a personal alternative that would change a data attribute instead, and initially thought it was a mistake on my end for the nonce.
After trying mode-watcher, I found out that it was behaving the same way as my attempt.
If that's normal could somebody explain, I don't see it replaced even when building the app and it got me confused.
The text was updated successfully, but these errors were encountered: