Use AWS Amplify Hosting to publish the React/Vite frontend as a production web application. This step should be completed after the Cognito User Pool is created and after the API Gateway Invoke URL is available from section 5.7.3.
Deploy the DocuFlow AI frontend from GitHub, configure production environment variables, verify the Amplify domain, and confirm the hosted application can call the backend API.
Before starting, prepare these values:
| Variable | Source |
|---|---|
VITE_COGNITO_REGION | AWS Region, for example ap-southeast-1 |
VITE_COGNITO_USER_POOL_ID | Cognito User Pool details page |
VITE_COGNITO_CLIENT_ID | Cognito App client details page |
VITE_API_BASE_URL | API Gateway stage Invoke URL from section 5.7.3 |
Do not put server-side secrets in Vite variables. Any variable prefixed with
VITE_is bundled into the browser application.


main.

apps/web

version: 1
applications:
- appRoot: apps/web
frontend:
phases:
preBuild:
commands:
- corepack enable
- pnpm install --frozen-lockfile
build:
commands:
- pnpm run build
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
- apps/web/node_modules/**/*

VITE_COGNITO_REGION=ap-southeast-1
VITE_COGNITO_USER_POOL_ID=ap-southeast-1_xxxxxxxxx
VITE_COGNITO_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxx
VITE_API_BASE_URL=https://xxxxxxxxxx.execute-api.ap-southeast-1.amazonaws.com/dev


https://main.xxxxx.amplifyapp.com
If refreshing a frontend route returns a 404 page, add a rewrite rule in Amplify:
| Source address | Target address | Type |
|---|---|---|
| `</^[^.]+$ | .(?!(css | gif |
Save the rule and redeploy the app if Amplify prompts you to do so.











raw/{userId}/{documentId}/original.pdf
If the browser reports a CORS error, update the API Gateway CORS configuration to allow the Amplify domain, then redeploy the API stage.