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:
<A href="/builder" force_refresh={true}>Builder</A>
<A href="/builder" force_refresh={true}>Builder</A>
When you click this link it forces a refresh rather than a silent navigation with a url change.
12 Replies
Madaxen86
Madaxen865d ago
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 route
gsoutz
gsoutzOP5d ago
I am not using solid start just solidjs frontend with no backend just netlify with github pages deploy
zulu
zulu5d ago
did you try window.location = "/builder" this might bypass the router
gsoutz
gsoutzOP5d ago
that probably might work. I will try it out.
zulu
zulu5d ago
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
gsoutz
gsoutzOP5d ago
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:
/builder
Cross-Origin-Embedder-Policy : require-corp
Cross-Origin-Opener-Policy : same-origin
Cross-Origin-Resource-Policy : same-site
/assets/*
Cross-Origin-Embedder-Policy : require-corp
Cross-Origin-Opener-Policy : same-origin
/builder
Cross-Origin-Embedder-Policy : require-corp
Cross-Origin-Opener-Policy : same-origin
Cross-Origin-Resource-Policy : same-site
/assets/*
Cross-Origin-Embedder-Policy : require-corp
Cross-Origin-Opener-Policy : same-origin
peerreynders
peerreynders5d ago
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.
zulu
zulu5d ago
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?
gsoutz
gsoutzOP5d ago
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.
zulu
zulu5d ago
you might be in a pickle
gsoutz
gsoutzOP2d ago
for now i reload both the iframe and wasm pages upon clicking a link. It works, except it breaks the SPA experience.
zulu
zuluthis hour
well you are lucky the wasm and the embeds are on different pages because then the whole experince would have been broken

Did you find this page helpful?