mmizutani / sbt-play-gulp

Gulp asset pipeline for Play Framework
Other
37 stars 12 forks source link

Issue or Question refresh the page or direct access to full url return to index page only #12

Closed almothafar closed 8 years ago

almothafar commented 8 years ago

Hi, I have an issue, i'm trying to make OAuth integration with my application, the problem is that When I go outside my webpage to login using Stripe as example, and comeback with parameter, its ignores the parameter, and event ignore that last place I was in and instead, I redirected to default page, as example: My default page : /ui/admin/home

I go to : /ui/admin/profile, then I click that button which redirect me to login page for Stripe, when I logged in I returned to the last page like /ui/admin/profile?scope=read_write&code=AUTHORIZATION_CODE but actually I just get the angular reloaded to /ui/admin/home

When I run the gulp serve externally I don't have this issue, I can refresh /ui/admin/profile and stay where I was, but inside the play I always return only to home page.

It's not about the parameter issue, I was just explain my story here, to clarify my issue:

The problem here that When I refresh page I lost it and instead I return to the default page, I can see that when I refresh the page I get the address in browser returns always to /ui/ then to the default state.

My routes:

# Home page
GET           /ui                                   com.github.mmizutani.playgulp.GulpAssets.index
GET           /ui/admin/                            com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base="/ui/")
GET           /ui/admin/*any                        controllers.Application.redirectToUI(any)
GET           /ui/admin                             com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base="/ui/")
->            /ui/                                  gulp.Routes
GET           /                                     com.github.mmizutani.playgulp.GulpAssets.redirectRoot(base="/ui/")

for redirectToUI function I tried to return :

return CompletableFuture.completedFuture(
                Results.redirect("/ui/").as("text/html")
       );

or return gulpAssets.redirectRoot("/ui/");

Why this method? because without it I get error 404 if I refreshed page.

And why /admin routes because access to /ui/ without /admin or /view or whatever after /ui/ I get the following exception:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:9000/ui/". And (index):1 Uncaught SyntaxError: Unexpected token < Tens of times in console and page not loaded, just screen with plan text with broken styles and images.

almothafar commented 8 years ago

I solved it with changing redirectToUI method to :

    @Inject
    private GulpAssets gulpAssets;

    public play.api.mvc.Action<AnyContent> redirectToUI(String any) {
        return gulpAssets.index();
    }

So it is return return gulpAssets.index(); instead of : return CompletableFuture.completedFuture(Results.redirect("/ui/").as("text/html"));

Thanks, was my mistake :)