我有一个 Angular 2 应用程序,它使用 ng2-file-upload 将文件上传到运行 Nginx 的服务器。当文件大小太大时,Nginx 肯定会发送 413,但浏览器(Chrome 和 Safari)似乎没有捕获/解释它。
Chrome 控制台错误:
XMLHttpRequest cannot load <url>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<url>' is therefore not allowed access. The response had HTTP status code 413.
Run Code Online (Sandbox Code Playgroud)
Safari 控制台错误
XMLHttpRequest cannot load <url>. Origin <url> is not allowed by Access-Control-Allow-Origin.
Run Code Online (Sandbox Code Playgroud)
Nginx 配置
server {
listen 80;
server_name <url>;
access_log /var/log/nginx/access.log main;
client_max_body_size 4m;
location / {
proxy_pass http://<ip address>:3009;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header …Run Code Online (Sandbox Code Playgroud) 所以我有一个相对较长的(在文本编辑器中)方程式,并且想知道最好是这样保持它还是重写它作为写入变量?有性能差异吗?
((((hoursPerWeek * (100 - percentageLoaded)) * (motorKw * 1.25) * 0.35) * 50) * (pencePerKwh / 100)) / 100
Run Code Online (Sandbox Code Playgroud)