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

prevent router from catching specified get request #417

Closed
yaron14 opened this issue Nov 26, 2019 · 3 comments
Closed

prevent router from catching specified get request #417

yaron14 opened this issue Nov 26, 2019 · 3 comments

Comments

@yaron14
Copy link

yaron14 commented Nov 26, 2019

My scenario:
Registration page with option to signup with google button.
If the user clicks the button it goes automatically to the fallback rout of page not found.

Is there an option to prevent from the client side router to catch specified requests and send it to the server?
Is it possible to redirect the user outside of the app and return him after successful signup/login?

Thanks in advanced

@vlukashov
Copy link

At the moment (v1.5.2) Vaadin Router does not have an easy way to exclude some in-app URLs from its own control and let the browser handle them. There is an open feature request: #325.

However, that limitation only applies to in-app links opened in the same window (e.g. all clicks at <a href="/my-app/some/url"> would be intercepted by Vaadin Router). This limitation does not apply to external links (e.g. <a href="https://accounts.google.com/o/oauth2/v2/auth">), nor to in-app links opened in another window (e.g. <a href="/my-app/some/url" target="_blank">).

It's not immediately obvious to me how is this Vaadin Router limitation blocking you from implementing a 'sign-in with Google' flow. Vaadin Router does not intercept external links like <a href="https://accounts.google.com/o/oauth2/v2/auth">.

Could you please give some more details? What triggers navigation to the external sign-up URL? Why is that navigation intercepted by Vaadin Router?

@yaron14
Copy link
Author

yaron14 commented Nov 27, 2019

The Google signup button in my app redirect to an end point that is not exists on the client, thus the router intercept it and redirects to not found page.

As you wrote your comment I found out it was my Express server middleware order issue.
I served a static client folder before the server side router and that's why every get request to an unspecified URL got intercepted.
I changed the order of the middlewares, first server side routers and afterwards GET with client side and it works fine.

The only issue I have now is that if I click the button straight from the app, Vaadin Router still intercept the request, but making the request from the URL search bar got me into the server.
What I ended up doing is prevent from the click to bubble up (preventDefault) and changed location.href to the required path.
Is there a nicer way of doing this using Vaadin Router methods?

@vlukashov
Copy link

I'm glad that you've found a workaround. Currently there is no nicer way to do it, and there is an open feature request to make it possible: #325. I'll close this issue as a duplicate.

If you have some ideas about the syntax or the API to exclude some paths from Vaadin Router scope, please share them on the linked issue.

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

2 participants