GithubHelp home page GithubHelp logo

Path prefix about grant HOT 6 CLOSED

simov avatar simov commented on April 28, 2024
Path prefix

from grant.

Comments (6)

simov avatar simov commented on April 28, 2024 1

I think it should work out of the box if you set your host property to localhost/v2/social and mount Grant with that prefix:

app.use('/v2/social', grant)

But I don't like using the host property like that, also I haven't tested it myself so it might not work. Either way I'll figure out the best way to add this feature these days. I'm also going to add a new example and I'll probably update the docs as well.

Thanks for contributing 👍

from grant.

arjanfrans avatar arjanfrans commented on April 28, 2024

I didn't mount grant directly on the app, but have a wrapper around it with some custom middleware added.

My server runs multiple express apps which are routed by Nginx, so express doesn't really know about the path.

For example, this is how we proxy in Nginx:

  • /v2/social -> express app A
  • /v2/api -> express app B

For this use case, it didn't work.

from grant.

simov avatar simov commented on April 28, 2024

Got it, that makes sense. I have NginX running on my workstation. It will take me some time to prepare everything but eventually this feature will be added one way or another. Just FYI the next release will be out by the end of this month.

from grant.

simov avatar simov commented on April 28, 2024

@arjanfrans take a look at the Path Prefix section.

In your case you just have to:

  1. Mount Grant as usual (without prefix).
  2. Set the path prefix using the path configuration option under the server key (this option is used only for generating the redirect_uri that you specify for your OAuth app).
  3. Prefix all your provider's callback configuration paths explicitly.

The reason why I'm not prefixing the callback paths automatically is because they are part of your own application. In other words the callback paths are not part of the Grant middleware, so the user shouldn't be forced to use the prefix there.

You can pull master and test if you want, in this case use the Alternative Require to require your fork.

Let me know what do you think.

from grant.

arjanfrans avatar arjanfrans commented on April 28, 2024

Looks good, I just tried it and it works. I agree on the automatic prefix on the callbacks, it is more flexible this way.

Thanks!

from grant.

simov avatar simov commented on April 28, 2024

Version 3.6.0 is published.

from grant.

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.