Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 2.98 KB

development-with-remote-api.md

File metadata and controls

62 lines (45 loc) · 2.98 KB

Development with remote API

Table of content

First setup for remote API

⚠️ Requirements

  • node needs to be installed. See nvmrc or the engines definition in package.json for version.
  • Coral uses pnpm (version 8) as a package manager. Read their official documentation how to install pnpm.

Step by step

  1. navigate to /coral
  2. run pnpm install
  3. run pnpm add-precommit the first time you install the repository to set the custom directory for our pre commit hooks.
  4. Run development: 4.1. If you have not set up a remote API mode, please follow First setup 4.2. If you already have a setup, run pnpm dev
  5. Create new Vite mode for remote API development
  6. When your API runs on https: Set up self-signed certificate

Create new Vite mode for remote API development

Start by creating a new Vite mode called .env.remote-api. The easiest way is to create one is to run the commend below. Note, that you need to replace the [KLAW API ORIGIN] placeholder value with your Klaw API server origin.

cat << EOF > .env.remote-api
NODE_ENV=development
VITE_PROXY_TARGET=[KLAW API ORIGIN]
VITE_API_BASE_URL=https://localhost:5173/api
VITE_SERVER_CERTIFICATE_PATH=".cert/localhost.crt"
VITE_SERVER_CERTIFICATE_KEY_PATH=".cert/localhost.key"
EOF

Set up self-signed certificate (required when API runs on HTTPS)

You can use Let's Encrypt instructions for setting up self-signed certificates for local development.

openssl req -x509 -out .cert/localhost.crt -keyout .cert/localhost.key \
    -newkey rsa:2048 -nodes -sha256 \
    -subj '/CN=localhost' -extensions EXT -config <( \
    printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost,IP:127.0.0.1\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Install .cert/localhost.crt in your list of locally trusted roots. This is different dependent on your OS, you can look up a current way to do this online. Keep in mind that dependent on your OS and browser, you may have to refresh that certificate from time to time.

How to run the project

If all requirements are met, and you've done your first setup:

  • pnpm run dev
  • login to Klaw with your credentials on <YOUR_LOCALHOST>:5173/login