[React/Apache2] Render SEO for web crawlers / set proxypass if crawlers detected

Job ID: 38368738

Budget: €8 – €30 EUR

Hello,

I did build a React app for screenshots hosting. The app works perfectly but now I'm faced to SEO issues.
I want that when a crawler access a screenshot, it send instantly meta tags, I used React Hemlet but the problem is that helmet put meta after a certain time so when a crawler access to a link, it didn't have the right and dynamic SEO.

Summary of the Issue

Problem:

- The goal is to have server-side rendering (SSR) for crawlers (search engines, social media bots) while serving a React app for regular users.
- Specifically, for URLs matching a specific pattern (e.g., /fd2ca2), crawlers should receive pre-rendered content for SEO purposes.
- Regular users should be served the React app for the same URLs.

Challenges:

- Configuring Apache to conditionally redirect or proxy requests based on the user-agent.
- Ensuring that the server-side rendered content is served correctly without breaking the React app.

Solutions Tested

1 - Initial Configuration:

- Set environment variables for known crawlers using SetEnvIfNoCase.
- Used RewriteCond and RewriteRule to proxy requests to the backend for URLs matching the pattern and user-agent.

2 - ProxyPassMatch Attempt:

- Tried using ProxyPassMatch within an <If> section to conditionally handle requests.
- This approach was invalid due to syntax constraints in Apache configuration.

3 - RewriteRule with Redirect:

- Used RewriteCond and RewriteRule to check the user-agent and URL pattern.
- Attempted to use ProxyPass and ProxyPassReverse to forward requests to the backend server.
- Encountered issues with request loops and incorrect path handling.

4 - Conditional Redirect:

- Attempted to conditionally redirect crawler requests to the backend using the Redirect directive within an <If> section.
- The configuration aimed to handle URLs matching the pattern and redirect them to the backend server while serving the React app for others.
- Despite efforts, encountered issues with proper handling and serving of the intended content.

Conclusion

The configurations tried so far involved using environment variables, conditional redirects, and proxy settings in Apache. Despite multiple approaches, achieving the desired behavior of serving SSR content to crawlers and React app to regular users has proven challenging due to the complexities of Apache's rewrite and proxy rules. I alswo tried with NGINX but facing the same issues.
Related categories: Linux SEO Link Building Nginx React.js