I am trying to read a GET request url that has the query strings after a '#' (out of my control) e.g:
http://...onnect/endpoint/#var_name=var_value...
request.url does not show anything after endpoint/
The problem can be dealt with if the endpoint renders html then i use javascript to get the query string, but that is what I am avoiding - is there a way to get the query string from the request.url or other request.[parameter] ?
CodePudding user response:
On the server you will never get the part that starts with #.
But on the client side you can get it with window.location.hash
.
What you can do if this is in your control, is to extract it from client side then send it to the server in some other way
CodePudding user response:
I was able to create a workaround (avoiding the need to create a Next.js page)
I created a redirect page using res.writeHead
and res.write
res.writeHead(302, { 'Content-Type': 'text/html' })
res.write(`
<script>
const queryString = window.location.hash.replace('#', '')
window.location.href='http://...onnect/endpoint?' queryString
</script>
`)
res.end()
Please if you have anything better feel free to answer.
Thank you.