···1616# (e.g., to debug production errors).
1717# GENERATE_SOURCEMAP=false
18181919-VITE_NOTION_PROXY_SERVER_URL=http://localhost:4000
1919+# URL of the content proxy service to use for content display in iframes.
2020+# This is used to proxy the content URL to the content proxy service.
2121+VITE_CONTENT_PROXY_URL=http://localhost:4000
2222+2323+# Comma-separated list of patterns to match content URLs that should be displayed in iframes
2424+VITE_CONTENT_URL_PATTERN=
···11-# Content Proxy Service Dockerfile
22-# Generic content proxy for iframe rendering with safety controls
33-44-# Stage 1: Build the application
55-FROM node:24.14.0-bullseye-slim AS builder
66-77-WORKDIR /app
88-99-COPY package*.json ./
1010-1111-RUN --mount=type=cache,target=/root/.npm npm ci --prefer-offline
1212-1313-COPY . .
1414-1515-RUN npm run build
1616-1717-RUN npm prune --omit=dev
1818-1919-FROM node:24.14.0-bullseye-slim
2020-2121-WORKDIR /app
2222-2323-COPY --from=builder /app/transpiled ./
2424-COPY --from=builder /app/node_modules ./node_modules
2525-2626-RUN npx playwright install --with-deps
2727-2828-EXPOSE 4000
2929-# commenting this out because playwright needs to be installed as the user that
3030-# is running the container.
3131-# TODO: figure out how to install playwright as a non-root user
3232-3333-# RUN groupadd -r coop && useradd -r -g coop -u 1001 -m coop
3434-3535-# RUN chown -R coop:coop /app
3636-3737-# # kubernetes requires us to use a numeric id for the user
3838-# USER 1001
3939-4040-CMD [ "node", "index.js" ]
-104
content-proxy/README.md
···11-# Content Proxy Service
22-33-A generic content proxy service for iframe rendering with safety controls, translation capabilities, and content sanitization.
44-55-## Features
66-77-- **Generic Content Support**: Works with any web content, not just specific platforms
88-- **Safety Controls**: Configurable blur and grayscale filters for images
99-- **Translation**: Google Translate integration for content localization
1010-- **Content Sanitization**: Removes scripts and unwanted UI elements
1111-- **Asset Proxying**: Handles CSS, images, and other static assets
1212-1313-## Environment Variables
1414-1515-| Variable | Description | Default |
1616-|----------|-------------|---------|
1717-| `PORT` | Server port | `4000` |
1818-| `GOOGLE_TRANSLATE_API_KEY` | Google Translate API key for translation features | Required for translation |
1919-| `CONTENT_BASE_URL` | Base URL for proxying assets (e.g., `https://www.example.com`) | `https://www.example.com` |
2020-2121-## Usage
2222-2323-### Basic Setup
2424-2525-1. Set environment variables:
2626- ```bash
2727- export GOOGLE_TRANSLATE_API_KEY="your-api-key"
2828- export CONTENT_BASE_URL="https://your-content-domain.com"
2929- ```
3030-3131-2. Install dependencies:
3232- ```bash
3333- npm install
3434- ```
3535-3636-3. Start the service:
3737- ```bash
3838- npm start
3939- ```
4040-4141-### API Endpoints
4242-4343-- `GET /` - Main content proxy endpoint
4444- - Query parameter: `contentUrl` - The URL of the content to proxy
4545- - Returns: HTML content with safety controls and translation features
4646-4747-- `GET /_assets/*` - Asset proxy for CSS, images, fonts, etc.
4848-- `GET /api/v1/ready` - Health check endpoint
4949-5050-### Client Integration
5151-5252-The service communicates with client applications via postMessage API:
5353-5454-```javascript
5555-// Send control commands to the iframe
5656-iframe.contentWindow.postMessage({
5757- type: 'customControl',
5858- blur: 2, // Blur level (0-10)
5959- grayscale: true, // Enable/disable grayscale
6060- shouldTranslate: false // Enable/disable translation
6161-}, 'https://your-proxy-domain.com');
6262-6363-// Listen for translation status updates
6464-window.addEventListener('message', (event) => {
6565- if (event.data.type === 'translationStatus') {
6666- console.log('Translation status:', event.data.isTranslating);
6767- }
6868-});
6969-```
7070-7171-## Configuration Examples
7272-7373-```bash
7474-export CONTENT_BASE_URL="https://your-platform.com"
7575-```
7676-7777-## Development
7878-7979-```bash
8080-# Install dependencies
8181-npm install
8282-8383-# Start development server with hot reload
8484-npm start
8585-8686-# Run tests
8787-npm test
8888-8989-# Build for production
9090-npm run build
9191-```
9292-9393-## Docker
9494-9595-```bash
9696-# Build image
9797-docker build -t content-proxy .
9898-9999-# Run container
100100-docker run -p 4000:4000 \
101101- -e GOOGLE_TRANSLATE_API_KEY="your-key" \
102102- -e CONTENT_BASE_URL="https://your-domain.com" \
103103- content-proxy
104104-```