cyntler / react-doc-viewer

File viewer for React.
https://cyntler.github.io/react-doc-viewer
Apache License 2.0
379 stars 125 forks source link

DocViewer requests twice. #154

Open engadori opened 1 year ago

engadori commented 1 year ago

Hi Cyntler.

When I using 'uri' props in 'DocViewer' component, It requests twice to my backend api.

here is my process. image when I request my file to backend, It needs 'Authorization' headers. The 'Next js API' was simply settings that headers

image

image

When I tested except 'Nextjs API', same result ( requesting twice ).

what should i do? plz give me some feedbacks.

alan-cushla commented 1 year ago

It makes a HEAD request followed by a GET. Could that be what you're seeing?

lskr802 commented 1 year ago

The first call might be a prefetch call followed by an actual API call.

By default prefetch use HEAD method call but can be overridden to make GET API call for prefetch as well.

;