1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Why am I seeing Error: 413 request entity too large in Nginx?

Discussão em 'Angular' iniciado por Jack, Novembro 4, 2024 às 17:02.

  1. Jack

    Jack Guest

    I have a problem when downloading large images, approximately more than 2 megabats.

    POST https://apis.mysite.com/apis/auth/ads net::ERR_FAILED 413 (Payload Too Large)

    I don't know what the problem is.

    In the Nginx settings I specified:

    client_max_body_size 100M;

    worker_processes 1;

    events {
    worker_connections 1024;
    }



    http {



    include mime.types;
    default_type application/octet-stream;

    sendfile on;
    keepalive_timeout 65;


    ssl_certificate ./ssl/mysite.crt;
    ssl_certificate_key ./ssl/mysite.key;


    client_max_body_size 100M;

    upstream apispring {

    server 127.0.0.1:8080;
    }




    server {

    listen 443 ssl;
    server_name apis.mysite.com;

    location / {
    proxy_pass http://apispring;


    }

    }



    server {


    listen 443 ssl;
    server_name mysite.com www.mysite.com;

    location / {
    root html;
    try_files $uri $uri$args $uri$args/ /index.html;
    }

    }



    }


    I also specified the Spring Boot settings

    server.port = 8080

    server.tomcat.threads.max = 200
    server.tomcat.connection-timeout = 5s
    server.tomcat.max-swallow-size = 2MB
    server.tomcat.max-http-form-post-size = 50MB

    server.max-http-request-header-size = 8KB

    spring.servlet.multipart.max-file-size = 50MB
    spring.servlet.multipart.max-request-size = 50MB


    I also use Angular

    previewImages: Set<string> = new Set();



    submit() {



    const ads: any = {
    phone: '1111111111',
    email: email@email.email,
    }



    const formData = new FormData();
    formData.append('ads', JSON.stringify(ads))

    let num = this.previewImages.size;
    let count: number = 0

    for (const [value] of this.previewImages.entries()) {
    formData.append(`img${count}`, value)
    count = count + 1
    if (count === num) {
    count = 0
    }

    }


    this.httpRS.addAds(formData).subscribe({
    next: () => {
    //
    }

    });


    }


    And my Spring Boot controller class

    @RestController
    @RequestMapping("/apis/auth")
    public class Ads {




    @PostMapping(value = "/ads", produces = "application/json")
    public viod addAds(@RequestParam(value = "img0", required = false) String img1,
    @RequestParam(value = "img1", required = false) String img2,
    @RequestParam(value = "ads") String ads) {

    // body

    }


    }


    Please tell me why this error occurs?

    Continue reading...

Compartilhe esta Página