Routing and configuration

Serve static assets

Attach the Link Vault browser interface as Worker static assets while keeping API routes and asset fallback behavior explicit.

8 minute lesson

~~~

A Worker project can deploy static assets with the application so one release contains both the interface and API.

Configure an assets directory and decide whether asset handling happens before or after Worker routing. Keep /api/* responses out of an HTML fallback, and use content-hashed assets or deliberate caching for updates.

Write the routing contract down before deploying it. A missing JavaScript file should be a 404, not the application’s HTML shell. An unknown browser route may use an HTML fallback, while an unknown API route must keep its JSON status and content type. Test all three cases directly rather than checking only the homepage.

Treat HTML and fingerprinted assets differently. HTML should update quickly because it points to the current filenames; content-hashed JavaScript and CSS can be cached much longer because a content change creates a new URL. A rollback must restore a compatible HTML-and-assets pair, which is easiest when both ship in the same versioned deployment.

Create an accessible link form and list page, bind the assets directory, and verify / and /api/health return different content types.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →