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.

react-helmet not fetched by social sites if API_URL points to server.js to retrieve data

See original GitHub issue

First of all. Amazing boilerplate, I’m really enjoying building my magazine with this.

So… Currently UserCard action points to a jsonplaceholder to retrieve data. Example A: const API_URL = 'https://jsonplaceholder.typicode.com/users';

In a real world case it could be fetched from server.js: Example B:const API_URL = '/api/article';

Example A & Example B both return the same data, the only difference is that Example B has to talk to the server instead of making a HTTP request.

I added react-helmet to UserCard:

export default ({ info }: Props) => (
  <div className={styles.UserCard}>
    <Helmet>
      <meta property="og:title" content={info.name} />
    </Helmet>
    <h4>User Card</h4>
    <ul>
      <li>Name: {info.name}</li>
      <li>Phone: {info.phone}</li>
      <li>Email: {info.email}</li>
      <li>Website: {info.website}</li>
    </ul>
  </div>
);

I am testing if the og:title is fetched by facebook’s open graph crawler using: https://developers.facebook.com/tools/debug/sharing/

If data is fetched via Example A, the open graph crawler fetches the {info.name} correctly.

If data is fetched via Example B, it does not fetch the {info.name}, it just returns the project’s default meta data from “config/default.js”

I’m unsure why this happens and would really love some advice with what the issue is here,

I realise that this is quite a specific issue, but this is the last step in deploying my magazine via this boilerplate - I would really appreciate any help.

Thank you in advance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
holodancommented, May 20, 2018

@wellyshen It’s working 😄 Thank you so much, I can’t believe how simple it was - I have been stuck on this for 2 months!

I can leave you alone now sorry 😆 Keep up the amazing work!

1reaction
holodancommented, May 17, 2018

@wellyshen Thank you very much, I have just re-updated my fork to resemble react-cool-starter with my additional changes to represent the issue. Please let me know if you need anything else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When fixing react-routing for production, fetch cannot find api url
This fetch request logs 'Error' when ran. It seems as though the url for the api is changing somehow as a result of...
Read more >
How to Use the Fetch API (Correctly) - CODE Magazine
Open the appsettings.json file and modify the connection string to point to your SQL Server where you installed the AdventureWorksLT database.
Read more >
4 Ways To Fetch Data in React - YouTube
In this video I will go over 4 ways you can fetch data in react from most basic to more advanced. I will...
Read more >
Access Data from an External API into a React Component
In this guide you will learn how to fetch JSON data from the GitHub Users API and render that data inside a React...
Read more >
How To Change the Title and Metadata with React Helmet
React Helmet is a component to dynamically manage the document's head section. Some common use cases include setting the title , description , ......
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