Giter Site home page Giter Site logo

iroha2-block-explorer-web's Introduction

iroha2-block-explorer-web

This repository is managed by Terraform!

Build

Node v20+ with Corepack is required.

corepack enable
pnpm i
pnpm build

Build artifacts will be located at dist dir.

Docker

Dockerfile with nginx.conf are also provided. Based on Deployment > Docker (nginx).

Development

Setting up the .env file

You need a file with environment variables to configure Vite for the frontend to properly request either mock data or interact with the backend.

To enable the mocks, write:

VITE_FAKE_API_ENABLED=TRUE

To interact with the backend, assuming you'll add an API proxy as described below, write:

VITE_API_URL=http://localhost:5173/api-proxy

Connecting to a BCE backend

One may want to see to see how the backend responds in the real time, but pointing the API endpoint directly in the VITE_API_URL property of an .env file would lead to a lot of errors like this one:

Access to fetch at 'http://localhost:port_A/...' from origin 'http://localhost:port_B' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Vite can be configured to proxy the responses.

So, we first return to the .env file and configure VITE_API_URL property as http://localhost:5173/api-proxy, if our dev shows the port as 5173.

Then we go to the Vite configuration in vite.config.js and add a new part in our defineConfig section, where our target points to the host and the port of our BCE backend instance.

export default defineConfig({
    server: {
        proxy: {
            '/api-proxy': {
                target: 'http://127.0.0.1:4000',
                changeOrigin: true,
                secure: false,
                ws: false,
                rewrite: (path) => '/api/v1' + path.replace(/api-proxy\//, ''),
            },
        },
    }
})

iroha2-block-explorer-web's People

Contributors

antyas avatar bastos525 avatar 0x009922 avatar 6r1d avatar baotn166 avatar wpi86 avatar

Stargazers

Roopesh Saravanan avatar

Watchers

Toshi Tsurumi avatar James Cloos avatar  avatar Albert Yagushev avatar Aleksandr Iakimov avatar Vladimir Pesterev avatar Igor Bisarnov avatar  avatar  avatar Stefan Popov avatar Bogdan Mingela avatar Ilia Churin avatar  avatar NaghmeMohammadifar avatar Sahil Dhiman avatar

iroha2-block-explorer-web's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.