Localhost issues with xampp

Hi, I cloned the slim-skeleton app and set

$app = AppFactory::create();
$app->setBasePath('/slim');

So I can run from localhost/slim. When connecting to http://localhost/slim/ I currently get the message

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

Here is my repository https://github.com/enfrte/slim-skeleton

Apache config is has AllowOverride All in the DocumentRoot of the project.

Anyone know what I have set wrong?

Thanks.

Hi!

I would try to fix it as follows:

  • Replace the two .htaccess files according to the docs as described here.
    Please just copy the two .htaccess exactly as they are documented. You don’t need to change it.

  • Comment out the wildcard route in routes.php

Thanks. I followed your recommendation and I’ve updated the repository. I now get the following…

{
    "statusCode": 404,
    "error": {
        "type": "RESOURCE_NOT_FOUND",
        "description": "Not found."
    }
}

Because you have two different App instances:

Thanks, it’s changed and pushed, but still get the same error.

I have tried to run your repo on my machine and it works. If you need consultancy, you can contact me directly.

Thanks, but I have it sorted. It turned out to be some weird browser thing. I’m using Brave browser which is based on chrome. If I opened a private window, it works just fine. If I even switch profiles, it works fine. I even disabled the pluggins (there were only 2), and Brave’s Sheilds up and still have the same issue. So I don’t know what the problem is, but I can mitigate by not using my current browser profile to to develop.

If anyone else has this issue, try a private window.

Thanks again.

Ok, after more thinking, I opened the network tab of the request and noticed it was actually a 301 being returned. I googled this for localhost and it turns out that browsers can cache this and will always serve it. So to get rid of it, you need to flush the cache (I actually flushed the browser history, but I think flushing the cache would do the same).

Don’t know why I didn’t think to investigate the network tab first, but live and learn peeps.

1 Like