From 58d91f78ab7303ead40829f47382d349c123941c Mon Sep 17 00:00:00 2001 From: DaX Date: Thu, 19 Jun 2025 00:38:50 +0200 Subject: [PATCH] Fix Next.js API route for Amplify WEB_COMPUTE platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add .env.production for Amplify environment variable mapping - Update artifacts configuration for WEB_COMPUTE platform - Add explicit nodejs runtime for API route - Enable serverActions in Next.js config - Add debugging output for environment variables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .env.production | 5 +++++ amplify.yml | 10 ++++++++-- app/api/filaments/route.ts | 2 ++ next.config.js | 5 ++++- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .env.production diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..b5bd761 --- /dev/null +++ b/.env.production @@ -0,0 +1,5 @@ +# This file is for Amplify to know which env vars to expose to Next.js +# The actual values come from Amplify Environment Variables +CONFLUENCE_API_URL=${CONFLUENCE_API_URL} +CONFLUENCE_TOKEN=${CONFLUENCE_TOKEN} +CONFLUENCE_PAGE_ID=${CONFLUENCE_PAGE_ID} \ No newline at end of file diff --git a/amplify.yml b/amplify.yml index 66cbe52..a1b8f2a 100644 --- a/amplify.yml +++ b/amplify.yml @@ -5,13 +5,19 @@ frontend: commands: - npm ci - npm run security:check + # Print env vars for debugging (without exposing values) + - env | grep CONFLUENCE | sed 's/=.*/=***/' build: commands: - npm run build artifacts: - baseDirectory: .next + baseDirectory: ./ files: - - '**/*' + - .next/**/* + - node_modules/**/* + - package.json + - next.config.js + - public/**/* cache: paths: - node_modules/**/* diff --git a/app/api/filaments/route.ts b/app/api/filaments/route.ts index 0aab978..5dc122c 100644 --- a/app/api/filaments/route.ts +++ b/app/api/filaments/route.ts @@ -1,6 +1,8 @@ import { NextResponse } from 'next/server'; import { fetchFromConfluence } from '../../../src/server/confluence'; +export const runtime = 'nodejs'; + export async function GET() { try { // Get environment variables from server-side only diff --git a/next.config.js b/next.config.js index 4b14fe3..a29a5db 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,10 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, - // Remove output: 'standalone' for Amplify + // Ensure server-side features are enabled + experimental: { + serverActions: true, + }, } module.exports = nextConfig \ No newline at end of file