How can I tell solid router to navigate to a page by forcing a refresh, breaking the SPA
I need to send specific CORS headers on a specific page which I can only do with netlify by specifying a link and the set headers. But when they navigate to home page and then click the link, the headers is not set because home page link doesn't set the headers by netlify not configured as such.
And I can't include the headers to be set on the home page as well. Because then contact page embedded video doesn't work because headers are too strict.
So the easiest workaround is the force a refresh on a specific link to force the netlify configuration to work for that link specifically.
Basically I need something like this:
When you click this link it forces a refresh rather than a silent navigation with a url change.
12 Replies
https://docs.solidjs.com/solid-start/advanced/middleware
You could use middleware
onRequest
which is still on the client to set specific headers for this routeI am not using solid start just solidjs frontend with no backend just netlify with github pages deploy
did you try
window.location = "/builder"
this might bypass the routerthat probably might work. I will try it out.
let me know i am curious too
another option is
<A href="/builder" target="_self">Builder</A>
see
https://docs.solidjs.com/solid-router/reference/components/a#soft-navigation
This solved the problem, but now I have to reload the page both for the wasm page to work with cors headers, and one with the iframe page that can embed twitch clips without the cors headers. I am not sure what is the best possible solution to this.
Now I am thinking reloading the page definitely is not the solution. I have to be able to set these headers for sharedarraybuffer wasm to work and also be able to embed twitch clips inside an Iframe:
According to MDN those header are
Response
headers, not Request
headers. So the server would have to respond with those headers to your Request
.
So I suspect that has more to do with your server configuration.i may not sure i understand the probem full scope , but why can't you set the permissive headers on all routes then there shouldn't be any reload needed?
Yes they are sent by the server and the code I pasted is server configuration. The thing is wasm needs the headers to be strict, and it works with the headers. but the Iframe needs the headers to be loose otherwise it doesn't show the frame.
you might be in a pickle
for now i reload both the iframe and wasm pages upon clicking a link. It works, except it breaks the SPA experience.
well you are lucky the wasm and the embeds are on different pages
because then the whole experince would have been broken