Skip to content

Commit a878e4f

Browse files
Merge pull request #1761 from rocket-admin/s3-bucket-providers
token interceptor: send extra headers only on RA requests
2 parents b08fd0b + bbcaccf commit a878e4f

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

frontend/src/app/services/token.interceptor.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,33 @@ export class TokenInterceptor implements HttpInterceptor {
3535

3636
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
3737
this.config = this._configuration.getConfig();
38-
const autoadmin_gclid_cookie = this.cookieService.get('autoadmin_gclid');
3938
const connectionID = this._connections.currentConnectionID;
39+
const url = new URL(request.url, location.origin);
40+
const isApiRequest = url.origin === location.origin || url.origin == 'https://app.rocketadmin.com';
4041

4142
request = request.clone({
4243
url: this.normalizeURL(request.url, environment.apiRoot || this.config.baseURL, environment.saasURL),
43-
setHeaders: {
44-
GCLID: autoadmin_gclid_cookie,
45-
},
46-
withCredentials: true,
4744
});
4845

49-
if (connectionID && !request.headers.has('masterpwd')) {
50-
const masterKey = localStorage.getItem(`${connectionID}__masterKey`) || '';
46+
if (isApiRequest) {
47+
const autoadmin_gclid_cookie = this.cookieService.get('autoadmin_gclid');
5148
request = request.clone({
5249
setHeaders: {
53-
masterpwd: masterKey,
50+
GCLID: autoadmin_gclid_cookie,
5451
},
52+
withCredentials: true,
5553
});
54+
55+
if (connectionID && !request.headers.has('masterpwd')) {
56+
const masterKey = localStorage.getItem(`${connectionID}__masterKey`) || '';
57+
request = request.clone({
58+
setHeaders: {
59+
masterpwd: masterKey,
60+
},
61+
});
62+
}
5663
}
64+
5765
return next.handle(request).pipe(
5866
catchError((error: HttpErrorResponse) => {
5967
if (error.status === 401) {

0 commit comments

Comments
 (0)