drodil / backstage-plugin-qeta

Backstage.io plugin for Q&A
https://www.npmjs.com/package/@drodil/backstage-plugin-qeta
MIT License
81 stars 25 forks source link

Images are not rendering back on UI, after image is saved in database #157

Closed ravindra-bh closed 3 months ago

ravindra-bh commented 3 months ago

Hi,

I was trying to use you QnA plugin, and found one issue.

When you ask a question and attach an image in the description of question. Images gets uploaded and saved in database. But when we try to browse question, image is not rendering on UI. see attached screenshot..

ImagesNotRenderingonUI

I tried to find the root cause, its happening because you are rending image in an tag which is directly hitting api (/api/qeta/attachments/) and this api needs authentication token, which is missing and hence request is not entertained by the server.

If you could provide some solution then it would be great.

drodil commented 3 months ago

Which versions of the plugins (front/backend) are you using? I think there was a fix for this in the recent release for the new backend system if I remember correctly

kedaroh-bh commented 3 months ago

Hi @drodil, Looks like after migrating to new backend system, image load is broken, backstage default auth policy do not allow request without auth token, and image load is implemented using html image tag for which is token is not getting set in auth header (fetchMiddlewares are not applied).

quick solution would be to skip attachments path from authPolicy as below, but we need to check how we pass token while loading images:

httpRouter.addAuthPolicy({
    allow: 'unauthenticated',
    path: '/attachments',
})
drodil commented 3 months ago

I think that change should be enough if I remember correctly. Any chance you could come up with a PR? I am on holiday so cannot really do code changes but I can review and release if necessary.

drodil commented 3 months ago

Closing this as resolved