json-server
json-server copied to clipboard
Return a blob or pdf from json-server
Hi everyone,
Is there a way to also return a file of type "application/pdf" / Blob type from a path using json-server? We have our mocked data under folder /issues/1.js so that it returns the mock json using URL /issues/1 but we would like to return a PDF from URL /issues/x/doc
Is this possible and how?
Thanks in advance! Thomas
Hi @thomashoef ,
Thanks for raising this issue! I understand your desire to return files like PDFs directly from json-server instead of relying on external solutions. While json-server primarily focuses and is primarily designed to serve JSON data, not raw files.
Alternative Solutions: External File Server: Host PDFs separately on a web server or file server and provide links or URLs to them. Custom Middleware: Extend json-server's functionality with custom middleware to handle file serving. Third-Party Libraries: Consider libraries like serve-static for static file serving.