2021年4月29日星期四

nginx/lumen API returns the request data

I have an API that is using Nginx as a web server and Lumen as a backend. Whenever I call an API endpoint, it returns the request data along with the expected data.

Something like this.

This is the request data:

{      "api_token": "abcd1234",      "lastname": "Doe",      "firstname": "John",      "birthdate": "1991-10-01",      "system_date": "2021-04-16"  }  

This is what nginx returns:

{  "api_token": "abcd1234",  "lastname": "Doe",  "firstname": "John",  "birthdate": "1991-10-01",  "system_date": "2021-04-16"  }{"error":false,"data":[{"LOANDESC":"Express  Loan","DATE":"2020-10-13","MATDATE":"2023-10-13","BALANCE":"55652.31","PRINDUEx":"-11014.37","INTDUEx":"35.56","PENDUEx":"0.00","NDD":"0  DAYS DELAYED - DELAYED BY  INSTALLMENT","CLIENTID":"00-00030503-7","SL_BRCODE":0,"SLC_CODE":12,"SLT_CODE":2,"REF_NO":25415,"INTEREST_RATE":"11.50000","PRINCIPAL_AMT":"80000.00","SHOULDBE_INTDUE":"4260.63","INTEREST_PAID":"4260.63","SHOULDBE_BALANCE":"66666.68","SHOULDBE_INSDUE":"0.00","INSDUE_PAID":"0.00","INSDUE":"0.00","MSG":"Diminishing  Balance Amortization type Loan Dues."}],"client":{"branch_id":0,"client_id":30503,"fullname":"John Doe","smsnumber":"639876543210","email_address":null}}  

What it should be returning:

{      "error": false,      "data": [          {              "LOANDESC": "Express Loan",              "DATE": "2020-10-13",              "MATDATE": "2023-10-13",              "BALANCE": "55652.31",              "PRINDUEx": "-11014.37",              "INTDUEx": "35.56",              "PENDUEx": "0.00",              "NDD": "0  DAYS DELAYED - DELAYED BY INSTALLMENT",              "CLIENTID": "00-00030503-7",              "SL_BRCODE": 0,              "SLC_CODE": 12,              "SLT_CODE": 2,              "REF_NO": 25415,              "INTEREST_RATE": "11.50000",              "PRINCIPAL_AMT": "80000.00",              "SHOULDBE_INTDUE": "4260.63",              "INTEREST_PAID": "4260.63",              "SHOULDBE_BALANCE": "66666.68",              "SHOULDBE_INSDUE": "0.00",              "INSDUE_PAID": "0.00",              "INSDUE": "0.00",              "MSG": "Diminishing Balance Amortization type Loan Dues."          }      ],      "client": {          "branch_id": 0,          "client_id": 30503,          "fullname": "John Doe",          "smsnumber": "639876543210",          "email_address": null      }  }  

I also use docker to setup and run the API.

Here is the default.conf of nginx:

server {      listen 80;      server_name localhost;      error_log /var/log/nginx/error.log;      access_log /var/log/nginx/access.log;      root /var/www/html;      index index.php index.html index.htm;        location / {          try_files $uri $uri/ /index.php?$query_string;      }        location /iaccs-api {          alias /var/www/html/iaccs-2013-api/public;          try_files $uri $uri/ @iaccs-api;            location ~ \.php$ {              include /etc/nginx/fastcgi_params;              fastcgi_param SCRIPT_FILENAME $request_filename;              fastcgi_pass webportal_php:9000;          }      }        location @iaccs-api {              rewrite /iaccs-api(.*)$ /iaccs-api/index.php?/$1 last;      }        location /webportal-api {          alias /var/www/html/iaccs-webportal-lumen/public;          try_files $uri $uri/ @webportal-api;            location ~ \.php$ {              include /etc/nginx/fastcgi_params;              fastcgi_param SCRIPT_FILENAME $request_filename;              fastcgi_pass webportal_php:9000;          }      }        location @webportal-api {              rewrite /webportal-api(.*)$ /webportal-api/index.php?/$1 last;      }        location /webportal {          alias /var/www/html/iaccs-webportal-client/public;          try_files $uri $uri/ @webportal;            location ~ \.php$ {              include /etc/nginx/fastcgi_params;              fastcgi_param SCRIPT_FILENAME $request_filename;              fastcgi_pass webportal_php:9000;          }      }        location @webportal {              rewrite /webportal(.*)$ /webportal/index.php?/$1 last;      }        location ~ \.php$ {          try_files $uri =404;          fastcgi_split_path_info ^(.+\.php)(/.+)$;          fastcgi_pass webportal_php:9000;          fastcgi_index index.php;          include fastcgi_params;          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;          fastcgi_param PATH_INFO $fastcgi_path_info;      }  }  

This is the docker-compose.yml

version: '3'    networks:    laravel:    services:    nginx:      image: nginx:stable-alpine      container_name: webportal_nginx      restart: unless-stopped      ports:        - "80:80"        - "443:443"      volumes:        - ./sites:/var/www/html        - ./nginx/default.conf:/etc/nginx/conf.d/default.conf      depends_on:        - php      networks:        - laravel      php:      build:        context: .        dockerfile: php.dockerfile      container_name: webportal_php      restart: unless-stopped      volumes:        - ./sites:/var/www/html      ports:        - "9000:9000"      networks:        - laravel  

I already tried to restart the docker containers a few times but the problem comes back after a while.

https://stackoverflow.com/questions/67326934/nginx-lumen-api-returns-the-request-data April 30, 2021 at 09:07AM

没有评论:

发表评论