Jhipster 不打开上传的文件

Jhipster doesn't open file uploaded

我有一个带有 JHipster 生成的 blob 字段的实体。在实体表单中我可以上传文件,表单正常提交。

当我在实体的视图页面或主页面尝试打开文件时出现问题。

浏览器打开此选项卡

并在控制台上打印以下消息。

Refused to frame '' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.

Spring 安全性中缺少某些配置?

我猜你使用的是 jHipster 6.2.0。

我遇到了同样的问题并确认这是来自 SecurityConfiguration.java(src/main/java/your_main_package/config 文件夹)。

等待官方更正,这是我在 configure 方法中评论的行,以解决错误:

.contentSecurityPolicy("default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://storage.googleapis.com; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; img-src 'self' data:; font-src 'self' https://fonts.gstatic.com data:")
    .and()
        .referrerPolicy(ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
    .and()
        .featurePolicy("geolocation 'none'; midi 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; fullscreen 'self'; payment 'none'")
    .and()