redoc icon indicating copy to clipboard operation
redoc copied to clipboard

redoc-cli serve does not load assets

Open malpiatko opened this issue 4 years ago • 4 comments

I would like to use redoc-cli serve while developing to see live updated to my site. However non of my images are loading. They all live in the same directory as where I call redoc. My dir structure is

/openapi
  openapi.yaml
/assets
  logo.png
template.hbs

From this directory I call: @npx [email protected] serve openapi/openapi.yaml --watch -t template.hbs Any way of making the images show up?

malpiatko avatar May 20 '20 18:05 malpiatko

Hello! you can create a symbolic link to assets in docs/assets/images/

ozeranskii avatar May 26 '20 10:05 ozeranskii

Thanks for your answer. I created docs/assets/images folder and moved all my images there however this unfortunately did not solve my issue. I had a brief look at the code and it seems that the request for images would fall into this else statement are return 404. https://github.com/Redocly/redoc/blob/5bace3008fa35c61d027eb621474246804fc4fcf/cli/index.ts#L190

Also with your solution what would the path be relative to?

malpiatko avatar May 26 '20 19:05 malpiatko

I get the same issue looks like the server doesn't expose any local assets and I can't seem to find any options I can pass as an argument to serve.

@ozeranskiy what did you mean by "creating a symbolic link"?

Cmdv avatar Jun 17 '20 14:06 Cmdv

You can embed the logo in base64 then it will load correctly, e.g.,

  x-logo:
    url: 'data:image/svg+xml;base64, ....base64 encoded here...'

fc avatar Feb 07 '22 21:02 fc