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

fetchConfig.configure destroys baseUrl? #149

Open
specimen151 opened this issue Aug 24, 2016 · 0 comments
Open

fetchConfig.configure destroys baseUrl? #149

specimen151 opened this issue Aug 24, 2016 · 0 comments

Comments

@specimen151
Copy link

this.fetchConfig.configure()    

seems to overwrite

this.http.baseUrl

So I need to set this.http.baseUrl again, after this.fetchConfig.configure() to get things working.

this.http is Aurelia's HttpClient.

My authConfig.ts does have a baseUrl already, so I keep setting this two places.

Please not that I've added an interceptor, according to receipes found here or elsewhere (don't remember) to forward to the login route in case of using a URL which points to an authenticated route without being authenticated:

http.configure(config => { 
      config
//        .useStandardConfiguration()
        .withBaseUrl(this.baseUrl)
          .withInterceptor({
            request(request) {
              console.log(`Intercepted request: ${request.method} ${request.url}`);
              return request;
            },
            response: response =>
            {
              console.log(`Intercepted response: ${response.status} ${response.url}`);
              if(response && response.status == 401) {
                this.authService.logout(null) // system won't login unless it's logged out for sure
                this.router.navigateToRoute('login');
                throw new Error('Not autherticated!');
              }
              return response;
            }
          });
      });
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

1 participant