Node.js server for dynamic meta tags, by providing a custom API route defining the details.
803
This Docker image provides a Node.js server designed to dynamically inject meta tags into your HTML files, enhancing SEO and link previews when sharing URLs. It's perfect for any single-page application built with React or similar frameworks.
You need to provide an API route that the server can query to fetch meta tags. The server sends a request to the API with the encoded URL of the current request. The API should return a JSON object containing the meta tags.
Assume the incoming request URL is https://example.com/page1. The server will encode this URL and make a request to the API:
GET https://api.example.com/meta?path=aHR0cHM6Ly9leGFtcGxlLmNvbS9wYWdlMQ==
Here, aHR0cHM6Ly9leGFtcGxlLmNvbS9wYWdlMQ== is the base64 encoding of https://example.com/page1.
The API should return a JSON object containing the meta tags for the requested URL:
{
"title": "Page Title",
"description": "Page Description",
"image": "https://example.com/image.jpg",
"icon": "https://example.com/favicon.ico"
}
version: '3.8'
services:
frontend:
hostname: frontend
image: bramkel/node-web-app:latest
container_name: "frontend-container"
restart: unless-stopped
ports:
- 3000:3000
environment:
- DEFAULT_TITLE=My Awesome App
- DEFAULT_DESCRIPTION=Discover and share the best content.
- API_URL=https://api.example.com/
volumes:
- /path/to/your/app:/react-app
docker run -d --name frontend-container -p 3000:3000 \
-e DEFAULT_TITLE="My Awesome App" \
-e DEFAULT_DESCRIPTION="Discover and share the best content." \
-e API_URL="https://api.example.com/" \
-v /path/to/your/app:/react-app \
bramkel/node-web-app:latest
docker pull bramkel/node-web-app:latest