Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App prefix #159

Open
yogevlahyani opened this issue Mar 22, 2020 · 8 comments
Open

App prefix #159

yogevlahyani opened this issue Mar 22, 2020 · 8 comments

Comments

@yogevlahyani
Copy link

Is it possible to configure app prefix or use it out-of-the-box when setting up app.setGlobalPrefix?

@williamdclt
Copy link
Collaborator

williamdclt commented Mar 26, 2020

I'm not sure I understand your issue. Using setGlobalPrefix does also set the prefix on the admin route.

For example, setting app.setGlobalPrefix('api') makes the admin login page be available at /api/admin/login

Are you encountering a problem with this behaviour?

@yogevlahyani
Copy link
Author

setGlobalPrefix does not apply the admin endpoint..

@yogevlahyani
Copy link
Author

But my question is whether you can define a different prefix for the admin module, for example if my global prefix is /v1, can the admin module prefix be /management and not /v1/management?

@williamdclt
Copy link
Collaborator

I can't seem to reproduce the global prefix not being applied. Do you have an example showing that?

There's no easy way to change the prefix no, I'm not aware of a way to ignore the global prefix in NestJS.

Something that could be done would be to create your own admin module (https://nestjs-admin.com/docs/custom-admin-module) independent from the rest of your app, where you'd have all the adminSite.register, then do something like this to start 2 applications: one for the admin and one for you actual application. But it means that you need to listen on 2 ports, and some reverse proxy to forward requests to the correct app depending on the prefix. I wouldn't do that unless I don't have a choice

@subotin94
Copy link

I think the problem here isnt the prefix, you can hit the route, but when you send an XHR, it should check if app has global prefix and attach it to the request url

@subotin94
Copy link

Current behavior is that it tries the req, it cuts your prefix from the route since it didnt hit it and then you end up on a not found page

@maksimoancha
Copy link

Current behavior is that it tries the req, it cuts your prefix from the route since it didnt hit it and then you end up on a not found page

Have the same issue. I'm using 'api' global prefix for my app, and can open login page at .../api/admin/login, but when click button to login, got "Not Found" error because request with my login info sended to ../admin/login indtead of .../api/admin/login. Do you found any solution?

@subotin94
Copy link

subotin94 commented Jun 5, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants