Error 405 Newly created project

Good Morning

I am new to the community I was looking for a framework that would help me in the creation of a restfull api I created a new project called api using the following command:

composer.phar create-project slim / slim-skeleton: dev-master api

Composer performed all the necessary operations successfully, the project was created within the publishing directory of my apache when accessing http: //localhost/api/public/index.php I am receiving the following error:

“statusCode”: 405,
“error”: {
“type”: “NOT_ALLOWED”,
“description”: “Method not allowed. Must be one of: OPTIONS”

I checked the path is correct for the file could someone help me understand what is this error?
I already released the apache mod_rewrite I’m not sure what is missing.

Hello @ederluca

I see two possible issues.

  1. The URL //localhost/api/public/index.php looks not correct. The public/ directory should never be part of the url path because it’s the document root of the webserver. Also the index.php is just the front controller and must never be part of the url. A correct URL would be for example: https://localhost/api. This means you need a route for /api in your routing definitions.

  2. The error Method not allowed. Must be one of: OPTIONS indicates that it could be an CORS preflight request issue. Setting up CORS