Skip to content

Bug: CI returns 200 OK even though the route does not exist #8009

Description

@xonipatino

PHP Version

8.2

CodeIgniter4 Version

4.4.1

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

No response

What happened?

Codeigniter 4.4.1 responds with code 200 OK when a Fetch request is made even if the route does not exist.

Steps to Reproduce

  1. These are my defined routes.
image
  1. In the browser, modify the 'action' attribute in the form for the 'usuarios/nuevo' route, placing it as 'usuarios/nuevoss', POST method.
image
  1. The request is sent and the response was 200 OK.
image
  1. And upon reviewing the response content it was the following.
{
    "title": "CodeIgniter\\Exceptions\\PageNotFoundException",
    "type": "CodeIgniter\\Exceptions\\PageNotFoundException",
    "code": 404,
    "message": "Can't find a route for 'post: usuarios/nuevoss'.",
    "file": "C:\\Users\\xonip\\www\\local_html\\macc\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
    "line": 966,
    "trace": [
        {
            "file": "C:\\Users\\xonip\\www\\local_html\\macc\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
            "line": 966,
            "function": "forPageNotFound",
            "class": "CodeIgniter\\Exceptions\\PageNotFoundException",
            "type": "::"
        },
        {
            "file": "C:\\Users\\xonip\\www\\local_html\\macc\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
            "line": 362,
            "function": "display404errors",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "C:\\Users\\xonip\\www\\local_html\\macc\\public\\index.php",
            "line": 79,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "C:\\Users\\xonip\\www\\local_html\\macc\\vendor\\codeigniter4\\framework\\system\\Commands\\Server\\rewrite.php",
            "line": 47,
            "args": [
                "C:\\Users\\xonip\\www\\local_html\\macc\\public\\index.php"
            ],
            "function": "require_once"
        }
    ]
}

Expected Output

The response code that CI should send is 404.

image

since the route 'usuarios/nuevoss' does not exist in the route declarations.

Anything else?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions