Giter Site home page Giter Site logo

Comments (12)

zhouzhuojie avatar zhouzhuojie commented on May 8, 2024 1

@lawrenceong How about #234?

from flagr.

zhouzhuojie avatar zhouzhuojie commented on May 8, 2024

FLAGR_WEB_PREFIX is for the UI prefix route only, we currently don't have a configurable API prefix route. PRs are welcome to add it.

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

Thanks @zhouzhuojie for the quick reply! We are using the following in nginx as a temporary workaround:

    set $flagr "http://flagr:18000";
    location /flagr {
        proxy_pass $flagr;
    }
    location /api/v1/flags {
        proxy_pass $flagr;
    }
    location /api/v1/evaluation {
        proxy_pass $flagr;
    }

Yes, I understand this does not include every possible endpoints, eg. /api/v1/health.

Will take a look at providing a PR when able.

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

@zhouzhuojie regarding a PR to allow the API URL to have a prefix.

I believe the parameter FLAGR_WEB_PREFIX should change the API prefix as well. From what I understand, webpack pre-generate the js file that contains the parameter API_URL. This means the only way we can change API_URL is to use relative pathing as how you have done in #223 with the static assets.

If we make API_URL relative, it will immediately start going to /webprefix/api/v1/*. To me, this means the API path should just be updated to make use of FLAGR_WEB_PREFIX. What do you think?

from flagr.

zhouzhuojie avatar zhouzhuojie commented on May 8, 2024

That is a breaking change. For example, people may have API runing at /api/v1 and web UI running at /ui, and then the change of reusing FLAGR_WEB_PREFIX for API will break their client SDK calls.

How about not setting FLAGR_WEB_PREFIX, and just proxy via nginx or any api-gateway with url strip (e.g. rewrite or proxy_pass), for example

example.com/webprefix/ => flagr.localhost:18000/, and you can get exactly what you want.

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

example.com/webprefix/ => flagr.localhost:18000/, and you can get exactly what you want.

@zhouzhuojie That does not actually work because the reverse proxy mechanism will only modify the headers. It does not touch the body which is where API_URL is located (redirecting to a hardcoded /api/v1/*).

This is why I have to revert to the above method to make it work in Nginx. ie. 3 different paths. This is regardless of whether we use FLAGR_WEB_PREFIX or not.

from flagr.

zhouzhuojie avatar zhouzhuojie commented on May 8, 2024

I see. We can make API_URL in the vue app as an environment variable when it's built, and then in Dockerfile, we pass that as a build arg. The downside is that you will have to build the docker image yourself.

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

Yup, I took a look at that solution too, but it's not elegant due to the need to rebuild. Basically looking for a solution where we do not have to rebuild the docker image.

Is it bad to have FLAGR_WEB_PREFIX move API path as well? I understand that it can be a breaking change if someone sets FLAGR_WEB_PREFIX and wants the API to remain at /api/v1. What is the chance that someone needs this?

Based on #223 (that was fixed less than 6 days ago), it looks like FLAGR_WEB_PREFIX may not be in use extensively yet. Would you be willing to accept this breaking change and move API based on FLAGR_WEB_PREFIX as well? This would allow us to map the entire app to a different path using a reverse proxy easily.

from flagr.

zhouzhuojie avatar zhouzhuojie commented on May 8, 2024

Yup, agreed, FLAGR_WEB_PREFIX was broken before #223

@SebastianOsuna, since you implemented #170, are you ok with using FLAGR_WEB_PREFIX to prefix both API and UI?

from flagr.

SebastianOsuna avatar SebastianOsuna commented on May 8, 2024

I agree it's a better solution!

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

So, I've been taking a look at submitting a PR for this and it looks like it's not all that simple. We generate the API using go-swagger and what's being generated does not allow us to overwrite the basePath. It looks like OpenAPI v3 allows us to override basePath, but that would mean an upgrade from v2 to v3 and go-swagger itself does not support v3.

  • For the frontend, we can just change /api/v1 to api/v2 without the leading /
  • For the backend, switch to another library to generate the API from swagger config?

from flagr.

lawrenceong avatar lawrenceong commented on May 8, 2024

@zhouzhuojie Looks good to me. Thank you.

from flagr.

Related Issues (20)

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.