This example demonstrates how to proxy uploads from your client application to Hygraph to prevent leaking the Permanent Auth Token needed to upload new assets.
Read more about this on our blog
npx degit hygraph/hygraph-examples/with-upload-proxy with-upload-proxyAdd .env:
cp .env.sample .envProvide values for HYGRAPH_TOKEN and HYGRAPH_ENDPOINT keys.
The HYGRAPH_TOKEN must have permission to create and read gassets.
The HYGRAPH_ENDPOINT must be appended with /upload.
Install & Run:
cd with-upload-proxy
npm install
npm run dev
# or
cd with-upload-proxy
yarn
yarn devOnce the server is running, make a request to http://localhost:4000/upload with your fileUpload using Content-Type: multipart/form-data.