Can't view pdf in editor mode on Firefox

Enonic version: 7.0.2
OS: Ubuntu

I have a Page for pdf files and on its controller the following code:

var url = portalLib.attachmentUrl({
     path: content._path,
     name: a_name

 return {
     redirect: url,
     contentType: content.attachments[a_name].mimeType

On Chrome, Safari and Edge it works fine in editor mode and I view the pdf in the draft/preview (center screen) but on Firefox I get a CORS error and the content studio keeps loading forever, not allowing any change in the content.
We are forcing download on Firefox for now but is there any solution for that?

Hmm, what is the purpose of this redirect? What are you actually trying to solve?

We have several PDF files in our site and when generating links for them we don’t send the usual attachment link but a common link (like from any other content) then we’ve set a template for all documents with a page that does this redirect, sending them to the attachment link.
What happens is, when opening a document in content studio this redirect still works rendering the PDF loaded but it seem to be loaded in an iframe, which generates a cors error when using Firefox.

Hmm, is it so that Content Studio and your site are on different domains? It works fine for me in Firefox when they are on the same domain. Anyway, you can easily avoid redirect by outputting the binary attachment stream directly (you’ll loose caching though):

var attachments = content.getAttachments(attachmentPath);
var attachmentStream = content.getAttachmentStream({
    key: attachmentPath,
    name: attachmentName

return {
    body: attachmentStream,
    contentType: attachments[attachmentName].mimeType
1 Like