Spaces:
Running
ml-tornidor
Local development
Since I use Cloudflare pages as hosting for this project there are some required steps to do before it's possible to start a local development environment. This project needs to wrap the node commands with the npx wrangler [...]
utility to emulate a Cloudflare Worker function. Because this worker function is under auth which use some env variables I to write these env variables inline. Every time I changed or added needed some variables I also needed to update the npx wrangler
command. To avoid this I prepared a js script, executed by Deno, that read the env variables from the .env
file composing the command:
- prepare the .env file copying the template.env file
- run the local environment using the command
pnpm dev
ordeno run -A runner.js
In case of new or updated packages Deno installs the dependencies at the first execution. Do it with a execution without the npx wrangler
wrapper:
deno run -A --node-modules-dir npm:vite
In case of problem:
- try executing again the command
deno run -A --node-modules-dir npm:vite
If this don't solve the problems try to
- delete the node_modules folder
- reinstall the npm packages with
pnpm install
- Run again the local development server, this time with the standard command
Before to commit try also to build using
pnpm build
Then run the preview (change the example variables):
npx wrangler pages dev --binding VITE_AUTH0_DOMAIN="example-auth0.eu.auth0.com" API_URL="https://example-aws.execute-api.eu-west-1.amazonaws.com/localhost/lambda-ml-fastsam-api" VITE_AUTH0_AUDIENCE="http://localhost-ml-lambda/" API_DOMAIN=example-aws.execute-api.eu-west-1.amazonaws.com CORS_ALLOWED_DOMAIN=http://localhost:8788 VITE_SATELLITE_NAME="tile-provider.image-type" -- pnpm preview