相关疑难解决方法(0)

在 NextJS、nginx 和 Material-ui(SSR) 中使用 CSP

TLDR:我在使用 Material-UI(服务器端渲染)为 NextJS 设置 CSP 并由 Nginx(使用反向代理)提供服务时遇到问题。

目前我在加载 Material-UI 样式表和加载我自己的样式时遇到问题

使用makeStyles来自@material-ui/core/styles

笔记:

default.conf (nginx)

# https://www.acunetix.com/blog/web-security-zone/hardening-nginx/

upstream nextjs_upstream {
  server localhost:3000;

  # We could add additional servers here for load-balancing
}

server {
  listen $PORT default_server;

  # redirect http to https. use only in production
  # if ($http_x_forwarded_proto != 'https') {
  #   rewrite ^(.*) https://$host$request_uri redirect;
  # }

  server_name _;

  server_tokens off;

  proxy_http_version …
Run Code Online (Sandbox Code Playgroud)

nginx content-security-policy material-ui next.js

2
推荐指数
1
解决办法
3271
查看次数