Google Chrome不能在react中预览PDF



Google Chrome不预览PDF,但会自动下载PDF。我检查了设置,一切正常。

Firefox -显示预览并且不自动下载。

我用的:

<embed
src={pdf-url}
type="application/pdf"
width="100%"
height="200px"
/>
<object
data={pdf-url}
width="300"
height="200"
/>

React-pdf -有问题,因为无法运行在webpack 3

有什么建议吗?

HTTP响应:

Request URL: server-url
Request method: GET
Status code: 200 
Remote address: **address**
Referrer policy: strict-origin-when-cross-origin
accept-ranges: bytes
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
cache-control: max-age=14400
cf-cache-status: REVALIDATED
cf-ray: 78ae088b5e152d37-KBP
content-length: 121539
content-type: application/octet-stream
date: Tue, 17 Jan 2023 09:23:39 GMT
etag: "f469b7190540ebbc1504b7491c05c587"
last-modified: Fri, 14 Oct 2022 14:50:01 GMT
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
report-to: {"endpoints":[{"url":url}],"group":"cf-nel","max_age":604800}

<embed
src='assets/test.pdf'
type="application/pdf"
width="100%"
min-height="200px"
/>

它在Google Chrome和Firefox中都可以正常工作

检查你的SRC地址,确保不要把/放在后面