diff --git a/RELEASE.md b/RELEASE.md index 24c8451cb..9d5a60963 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -220,8 +220,8 @@ Empty means it is safe to fast-forward and something else is wrong (branch protection, most likely). Not empty means there is work on `release` to merge back into `main` first. -Amplify builds the branch. Its build settings live in the Amplify console, not -in this repo, so there is no `amplify.yml` here to change. +Amplify builds the branch from `amplify.yml` in this repo. A branch that +contains it ignores the build settings in the Amplify console. ## Windows installer payloads diff --git a/amplify.yml b/amplify.yml new file mode 100644 index 000000000..abd3c30c7 --- /dev/null +++ b/amplify.yml @@ -0,0 +1,18 @@ +version: 1 +frontend: + phases: + preBuild: + commands: + - npm config set "@fortawesome:registry" https://npm.fontawesome.com/ + - npm config set "//npm.fontawesome.com/:_authToken" $FONT_AWESOME_AUTH_TOKEN + - npm install + build: + commands: + - if [ "$AMPLIFY_PREVIEW" = true ]; then . ./scripts/amplify-preview-env.sh; fi; npm run build-frontend + artifacts: + baseDirectory: frontend/build + files: + - '**/*' + cache: + paths: + - node_modules/**/* diff --git a/readme.md b/readme.md index b9ac37f63..724594a41 100644 --- a/readme.md +++ b/readme.md @@ -122,6 +122,14 @@ Leave `VITE_OAUTH_CLIENT_ID` as `remoteit_desktop` locally. Redirect URIs are re branch config makes authorize fail with a 400. `remoteit_desktop` carries both `http://localhost:3003/authCallback` and `remoteit://authCallback` (the Electron deep link). +Branch previews build on the dev stage as `remoteit_portal`. Amplify autodetects `feat/**` and +`fix/**` branches pushed to this repo, deploys each to its own `*.d20k671nqqv4kl.amplifyapp.com` +address and drops it when the branch is deleted. Its auto-created branch config sets +`AMPLIFY_PREVIEW=true`, which makes `amplify.yml` source `scripts/amplify-preview-env.sh`. Sign-in +needs `https://*.d20k671nqqv4kl.amplifyapp.com/authCallback` and `/signoutCallback` registered on +dev's `remoteit_portal`. That wildcard is safe only while nothing from outside this repo can deploy +under the app's domain, so keep Amplify's **pull request previews off**: they build PRs from forks. + Browse to `http://localhost:3003` exactly. `npm start` binds `0.0.0.0`, but reaching the app over a LAN IP is a non-secure origin, where `crypto.subtle` is unavailable and the DPoP proofs every token call carries silently degrade. diff --git a/scripts/amplify-preview-env.sh b/scripts/amplify-preview-env.sh new file mode 100644 index 000000000..f9711e991 --- /dev/null +++ b/scripts/amplify-preview-env.sh @@ -0,0 +1,9 @@ +# Sourced by amplify.yml for branch previews: the branches Amplify autodetects, whose auto-created +# branch config sets AMPLIFY_PREVIEW=true. A preview also gets the app-level environment, and the app +# level pins the legacy production API, so a preview would otherwise sign in as remoteit_desktop on +# login.remote.it. Pinning the dev issuer selects STAGES.dev for the rest. +unset VITE_GRAPHQL_API VITE_WEBSOCKET_URL VITE_OAUTH_GRAPHQL_RESOURCE VITE_OAUTH_AGENT_RESOURCE VITE_OAUTH_MCP_RESOURCE VITE_OAUTH_MCP_DETAIL +export VITE_OAUTH_ISSUER=https://login.dev.remote.it +export VITE_OAUTH_CLIENT_ID=remoteit_portal +# A pinned build otherwise calls the agent at /agent, which only the vite dev server proxies. +export VITE_AGENT_URL=https://agent.dev.remote.it