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

Fix 404 - when url entered directly into the browser #92

Open
wants to merge 2 commits into
base: master
from

Conversation

@isneezy
Copy link

@isneezy isneezy commented Feb 18, 2020

I've fixed the White Label error with a simple filter by reusing the existing REGEX
The only catch up with this approach is that if you plan to have other URLs other than /api ex: /oauth etc you'll have to include them in the REGEX expression

Fixes #41

@coveralls
Copy link

@coveralls coveralls commented Feb 18, 2020

Pull Request Test Coverage Report for Build 497

  • 18 of 18 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+6.4%) to 91.304%

Totals Coverage Status
Change from base Build 495: 6.4%
Covered Lines: 63
Relevant Lines: 69

💛 - Coveralls
@isneezy isneezy marked this pull request as ready for review Feb 18, 2020
@isneezy isneezy requested a review from jonashackt Feb 18, 2020
@@ -52,12 +52,4 @@ public User getUserById(@PathVariable("id") long id) {
return SECURED_TEXT;
}

// Forwards all routes to FrontEnd except: '/', '/index.html', '/api', '/api/**'
// Required because of 'mode: history' usage in frontend routing, see README for further details
@RequestMapping(value = "{_:^(?!index\\.html|api).*$}")

This comment has been minimized.

@hemeroc

hemeroc Sep 13, 2020

The forward in this rule did not work for two reasons

  1. it was placed int he wrong RequestMapping context as it would look for the pattern only after /api
  2. it was placed in a RestController instead of a Controller that does not support returning a forwad:/

Although the filter probably does work the easier solution would be to just fix 1) & 2)

This comment has been minimized.

@isneezy

isneezy Sep 25, 2020
Author

Thanks for the info, I didn't knew about it! I'll see if it works and I'll update the PR in the mean time

This comment has been minimized.

@isneezy

isneezy Oct 6, 2020
Author

@hemeroc I've tried to follow your idea, you were right about the using Controller instead of RestController but unfortunately, this solution only works on one level URLs like this /login but not for this /auth/login or any URL that has many deep level path as you can see the tests here:

void redirectSpa() {
ValidatableResponse response = RestAssured.when().get("/path").then();
assertSpaResponse(response);
response = RestAssured.when().get("/nested/path").then();
assertSpaResponse(response);
response = RestAssured.when().get("/deep/nested/path/with/many/may/deep").then();
assertSpaResponse(response);
}

Do you have any idea on how to match URLs with multiple levels?

This comment has been minimized.

@isneezy

isneezy Nov 16, 2020
Author

I've found a way to accomplish using @Controller instead of Filter I'll update as soon as possible

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

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.