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-proxy
Add .env:
cp .env.sample .env
Provide 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 dev
Once the server is running, make a request to http://localhost:4000/upload
with your fileUpload
using Content-Type: multipart/form-data
.