TheOpenPresenter
  • Introduction
    • Welcome
    • Motivation & Challenges
    • System Architecture
    • Terminologies
    • Server Communication
    • Project Topology
  • Development
    • Quickstart
    • Static files
    • Media Storage
  • Plugins
    • Introduction
    • Official Plugins
      • Google Slides
      • Lyrics Presenter
        • Lyrics compatibility
      • Video Player
      • Audio Recorder
    • Developing a Plugin
      • Plugin API
        • Yjs
          • Awareness
          • Scene
          • Renderer
        • Backend
          • Yjs Handler
          • Loading Frontend
          • Security
        • Frontend
          • Remote
          • Renderer
        • Media
          • Server Plugin API
          • Frontend
            • Tus
            • Form Data
        • TRPC
        • Database
      • Audio
      • Viewer State
      • Notifying Errors
      • Caveats
        • Sharing dependencies
        • Cross-over between plugins
      • Performance
  • API Reference
    • Plugin Context
  • Guide
    • Playing Audio
    • Listen to scene changes
  • Scratch Pad
    • Ambition
    • Background music
  • Environment Variables
  • External
    • Page 1
Powered by GitBook
On this page
  1. Development

Static files

Some plugins may require us to serve many different media files. Rather than storing these in the main repo, they are stored in https://github.com/Vija02/theopenpresenter-static/

One way to access these files is directly through the github URL

However, to prevent CORS/ORB issue, it is recommended that you serve this file from a domain you control. There are many ways to do this like deploying a static server or proxying github.

Here is an example on how to handle this through a Cloudflare Worker:

export default {
  async fetch(request) {
    const url = new URL(request.url);
    
    // Construct the GitHub raw URL
    const githubUrl = url.pathname === '/' 
      ? 'https://raw.githubusercontent.com/Vija02/theopenpresenter-static/refs/heads/main'
      : `https://raw.githubusercontent.com/Vija02/theopenpresenter-static/refs/heads/main${url.pathname}`;

    // Fetch from GitHub
    const response = await fetch(githubUrl, {
      cf: {
        // Cache in Cloudflare's CDN for 1 year
        cacheTtl: 31536000,
        cacheEverything: true,
      }
    });
    
    // Clone the response and add CORS headers
    const newResponse = new Response(response.body, response);
    newResponse.headers.set('Access-Control-Allow-Origin', '*');
    newResponse.headers.set('Cache-Control', 'public, max-age=31536000, immutable');
    
    return newResponse;
  }
};

Configuration

By default, we will directly use the github link to access the files. To override this, define a new path in the STATIC_FILES_PATH environment variable.

PreviousQuickstartNextMedia Storage

Last updated 6 months ago