I try to open an image in a new window in an angular app using window.open(url). But the new window is redirected to the angular app instead of loading the resource.
My angular app is hosted on example.fr, with base path="/", and i try to load an image hosted on example.fr/api/image.png.
When i open the link in private mode everything works fine.
I'm on angular 7.2, using a service worker.
I tried to specify the absolute url (with protocol and hostname) in window.open, but it does not help.
It works if I bypass the service worker in the Chrome dev tools.
file-preview.component.html :
<span (click)="openImage()">Open image in new window</span>
file-preview.component.ts :
import { Component, OnInit } from '@angular/core'
@Component({
selector: 'app-file-preview',
templateUrl: './file-preview.component.html'
})
export class FilePreviewComponent implements OnInit {
openImage() {
window.open('https://example.fr/api/image.png')
}
}