examples/proxy-auth/README.md
This example implements the proxy auth pattern for securing access to the Electric sync service.
It demonstrates how an API can proxy and authorise shape requests, by either:
https://github.com/user-attachments/assets/eab62c23-513c-4ed8-a6fa-249b761f8667
[!TIP] You can see an alternative pattern for auth in the gatekeeper-auth example.
This example is part of the ElectricSQL monorepo and is designed to be built and run as part of the pnpm workspace defined in ../../pnpm-workspace.yaml.
Navigate to the root directory of the monorepo, e.g.:
cd ../../
Install and build all of the workspace packages and examples:
pnpm install
pnpm run -r build
Navigate back to this directory:
cd examples/proxy-auth
Start the example backend services using Docker Compose:
pnpm backend:up
Note that this always stops and deletes the volumes mounted by any other example backend containers that are running or have been run before. This ensures that the example always starts with a clean database and clean disk.
Now start the dev server:
pnpm dev
When you're done, stop the backend services using:
pnpm backend:down