[英]multipart/form-data post request getting CORS error with Angular 7 and spring boot, only when image size is more than 1 mb
我有一個 spring 啟動應用程序,其中 controller 正在使用內容類型“多部分/表單數據”的發布請求。 此代碼在圖像大小小於 1MB 時有效,但如果我上傳任何大小超過 1MB 的圖像,我總是會遇到此錯誤。 此錯誤僅出現在生產環境中。 在本地系統中,這工作得很好。 錯誤
我已經在 spring 引導應用程序屬性文件中增加了多部分文件最大大小的默認大小。
#Spring max size upload
spring.servlet.multipart.max-file-size=10MB
spring.servlet.multipart.max-request-size=10MB
spring.servlet.multipart.enabled=true
#Server properties
server.tomcat.max-http-post-size=100000000
server.tomcat.max-swallow-size=100000000
我正在使用 Nginx 來解決問題所在的負載平衡。 當我從 AWS 增加 Nginx 的大小時。 錯誤得到解決。
我關注了這個博客來增加大小。 您必須需要 root 權限才能更新您的 Nginx 配置文件
https://medium.com/@ghazaltaimur27/change-file-upload-limit-in-ngnix-in-aws-server-2820c491e9a4
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.