diff --git a/apps/web/next.config.js b/apps/web/next.config.js index bc4a6dc..80b19a3 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -1,3 +1,11 @@ +/** The sites that may frame the home page's office (localhost for their dev servers). */ +const FRAME_ANCESTORS = [ + "'self'", + 'https://starfish.sh', + 'https://www.starfish.sh', + 'http://localhost:*', +]; + /** @type {import('next').NextConfig} */ module.exports = { transpilePackages: ['@agentopia/lib', '@agentopia/viewer', '@agentopia/core'], @@ -21,7 +29,8 @@ module.exports = { headers: [{ key: 'Vary', value: 'Accept' }], })), { - source: '/(.*)', + // Every page but the home page refuses to be framed. + source: '/:path+', headers: [ { key: 'Content-Security-Policy', @@ -33,6 +42,16 @@ module.exports = { }, ], }, + { + // The home page is the office alone, so the sites allowed may show it in an iframe. + source: '/', + headers: [ + { + key: 'Content-Security-Policy', + value: `frame-ancestors ${FRAME_ANCESTORS.join(' ')};`, + }, + ], + }, ], images: { remotePatterns: [