location.href is not available in SSRsome mistakes are coming from using location.href in server side rendering - but there is no place in docs where is a hint about this
-const href = location.href
+const href = `${siteUrl}${pathname}`
https://css-tricks.com/how-to-the-get-current-page-url-in-gatsby/#article-header-id-4
maybe placing infos here:
On top of documention, we can make trying to access location.href to throw error in code (which would contain link to appropriate docs. Alternatively we could maybe construct .href for SSR? But I feel like constructing it ourselves might just hide some problems and introduce even more problems (subtle, and hard to debug)
Also ran into this, using location.href for meta tags, which have to be SSRd. I think Gatsby should:
location in SSR/buildtimelocation.href when it's not availablelocation.pathname and the site's canonical URL insteadI don't think Gatsby should try and construct location.href in SSR envs. It's pretty trivial to do yourself, and far less opaque. Just needs to be documented, and not silently fail.
Can i work on this documentation ?
Sure @imrishabh18, we would love your contribution!
@marcysutton Hey, can you please help me what should i write in the docs ?
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Not stale, still needs a fix AFAIK
Hiya!
This issue has gone quiet. Spooky quiet. 馃懟
We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!
Thanks for being a part of the Gatsby community! 馃挭馃挏
Still not stale
Most helpful comment
On top of documention, we can make trying to access
location.hrefto throw error in code (which would contain link to appropriate docs. Alternatively we could maybe construct.hreffor SSR? But I feel like constructing it ourselves might just hide some problems and introduce even more problems (subtle, and hard to debug)