Public Access
1
0

feat: add proxy middleware for API requests and create production Docker Compose setup

This commit is contained in:
2025-08-23 11:27:40 -04:00
parent abfac06908
commit 0327ef81a6
5 changed files with 142 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
module.exports = function(eleventyConfig) {
const { createProxyMiddleware } = require('http-proxy-middleware');
// Pass through static assets from the "src" directory
eleventyConfig.addPassthroughCopy("src/css");
@@ -42,6 +43,21 @@ module.exports = function(eleventyConfig) {
// Add a shortcode for the current year for the footer
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
// Only add the proxy middleware when in serve mode
if (process.env.ELEVENTY_RUN_MODE === "serve") {
// Dev server options
eleventyConfig.setServerOptions({
// When the site is served by Eleventy's dev server, proxy API requests
// to the API server which is running in a separate container.
middleware: [
createProxyMiddleware('/api', {
target: 'http://api:3000', // The 'api' service container
changeOrigin: true,
}),
],
});
}
return {
// Set the source and output directories
dir: {