question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docs: add info about location.href

See original GitHub issue

Summary

  • add section about location.href is not available in SSR

Motivation

some 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}`

References

https://css-tricks.com/how-to-the-get-current-page-url-in-gatsby/#article-header-id-4

Steps to resolve this issue

Docs

maybe placing infos here:

Draft the doc

Open a pull request

  • Open a pull request with your work including the words “closes #[this issue’s number]” in the pull request description

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
piehcommented, Mar 5, 2020

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)

1reaction
ehrencronacommented, Jun 16, 2020

To provide an error message in this situation, there needs to be a change to reach/router. I’ve submitted an issue and a PR on reach that should fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Work with links & bookmarks - Google Docs Editors Help
Add a link · Open a file in the Google Docs, Sheets, or Slides app. · Docs: Tap Edit · Highlight text or...
Read more >
location.href - Web APIs | MDN
The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to...
Read more >
Location href Property - W3Schools
The location.href property sets or returns the entire URL of the current page. Syntax. Return the href property: location.href.
Read more >
pass post data with window.location.href - Stack Overflow
What you have to do is to set up a form tag with data fields in it, set the action attribute of the...
Read more >
Localized Versions of your Pages | Google Search Central
Add <link rel="alternate" hreflang=" lang_code "... > elements to your page header to tell Google all of the language and region variants of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found