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

routing? #8

Open
ahmeed83 opened this issue Sep 25, 2019 · 4 comments
Open

routing? #8

ahmeed83 opened this issue Sep 25, 2019 · 4 comments

Comments

@ahmeed83
Copy link

ahmeed83 commented Sep 25, 2019

Everything works after i finished the steps mentioned in this page.
However I want to add routing to the page and that doesn't work. Anyone has an idea how to solve it?

@muenchto
Copy link

muenchto commented Oct 9, 2019

same problem here

@Jingli2017
Copy link

same

@TranNgocKhoa
Copy link

My current solution is HashRouter. But I don't think it's a perfect solution

@TranNgocKhoa
Copy link

Another solution with BrowserRouter. This works with Swagger too.

@Configuration
public class WebConfig {

    @Bean
    public WebMvcConfigurer reactRoutingMapper() {
        return new WebMvcConfigurer() {
            @Override
            public void addViewControllers(ViewControllerRegistry registry) {
                // Map "/"
                registry.addViewController("/")
                        .setViewName("forward:/index.html");
                // Map "/word", "/word/word", and "/word/word/word" - except for anything starting with "/api/..." or ending with
                // a file extension like ".js" - to index.html. By doing this, the client receives and routes the url. It also
                // allows client-side URLs to be bookmarked.

                // Single directory level - no need to exclude "/api" and "/swagger-ui.html"
                registry.addViewController("/{x:[\\w\\-]+}")
                        .setViewName("forward:/index.html");
                // Multi-level directory path, need to exclude "api" on the first part of the path
                registry.addViewController("/{x:^(?!\\/api|\\/swagger\\-ui\\.html).*$}/**/{y:[\\w\\-]+}")
                        .setViewName("forward:/index.html");
            }
        };
    }
}

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