serverless-wsgi icon indicating copy to clipboard operation
serverless-wsgi copied to clipboard

404: The requested URL was not found on the server

Open lfpratik opened this issue 3 years ago • 2 comments

The request gets fail and return the following error

{
    "statusCode": 404,
    "headers": {
        "Content-Type": "text/html; charset=utf-8",
        "Content-Length": "232"
    },
    "body": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>404 Not Found</title>\n<h1>Not Found</h1>\n<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>\n",
    "isBase64Encoded": false
}

Request Event

{
  "httpMethod": "GET",
  "path": "/data?user=lfpratik",
  "resource": "/:proxy",
  "queryStringParameters": {
    "user": "lfpratik"
  },
  "pathParameters": {
    "proxy": "data"
  },
  "headers": {
    "host": "localhost",
    "user-agent": "curl/7.51.0",
    "accept": "*/*",
    "content-type": "application/json",
    "day": "Thursday",
    "content-length": "18"
  },
  "requestContext": {
    "apiEndpoint": {
      "apiEndpointName": "default",
      "host": "*",
      "path": "/:proxy",
      "paths": "/:proxy",
      "scopes": []
    },
    "resourcePath": "/:proxy",
    "httpMethod": "GET",
    "requestId": "3SpeBYb8SK6CvH7Ipx56pK"
  },
  "isBase64Encoded": false,
  "body": ""
}

lfpratik avatar Dec 15 '21 10:12 lfpratik

Step to produce issue

Requirements:

python: 3.9
Node: 17.0.1
---------------------------------------------
"serverless": "^2.68.0",
"serverless-python-requirements": "^4.3.0",
"serverless-wsgi": "^3.0.0"

Clone following repository

git clone https://github.com/lfpratik/serverless-flask-sample.git

Run the following command to setup environment

make devenv
make node_modules

Execute following serverless invoke function command and observe the output

sls invoke local -f app --path data.json

Input request generated from following plugin express-gateway-plugin-lambda

{
  "httpMethod": "GET",
  "path": "/data?user=lfpratik",
  "resource": "/:proxy",
  "queryStringParameters": {
    "user": "lfpratik"
  },
  "pathParameters": {
    "proxy": "data"
  },
  "headers": {
    "host": "localhost",
    "user-agent": "curl/7.51.0",
    "accept": "*/*",
    "content-type": "application/json",
    "day": "Thursday",
    "content-length": "18"
  },
  "requestContext": {
    "apiEndpoint": {
      "apiEndpointName": "default",
      "host": "*",
      "path": "/:proxy",
      "paths": "/:proxy",
      "scopes": []
    },
    "resourcePath": "/:proxy",
    "httpMethod": "GET",
    "requestId": "3SpeBYb8SK6CvH7Ipx56pK"
  },
  "isBase64Encoded": false,
  "body": ""
}

lfpratik avatar Dec 15 '21 13:12 lfpratik

I haven't seen the query string parameters showing up in path before. Do you know when this happens?

logandk avatar Apr 04 '22 07:04 logandk