skip to Main Content

I am trying to do an uptime check of my Laravel application.
Essentially, I want to be able to login, and check that the home pages has loaded successfully via curl or similar.

I am using the below curl command:

curl -v -X POST -F '[email protected]&password=my_password' https://myurl.com/login

When I run this, I get a 405 Method Not Allowed exception page in my response.

When I login via the browser, I have made the following observations in my network inspector:

1st request: POST 302 – https://myurl.com/login
2nd request: GET 302 – https://myurl.com/
3rd request: GET 200 – https://myurl.com/ – my homepage is now loaded

I am unsure if there is a way to follow this in curl, or if this is the normal behaviour of Laravel login, or if some custom behaviour we have is causing this?

Is there a better way for me to validate that the homepage is up and running myself or with any suggested external services?

2

Answers


  1. Here are a few cURL checks you can use to see if your Laravel homepage is operational:

    To submit a POST request to the /login endpoint, use the -X POST option. If the login is successful, this will imitate the login procedure and return a 200 OK response.

    curl -X POST -F '[email protected]&password=my_password' https://myurl.com/login
    

    To follow redirection, use the -L option. This will guarantee that cURL adheres to any redirection that the server returns. This is required because, once you have successfully logged in, the login process usually redirects you to the homepage.

    curl -L -X POST -F '[email protected]&password=my_password' https://myurl.com/login
    

    Get verbose output by selecting the -v option. The HTTP request and response headers will be displayed, which might be useful for troubleshooting.

    curl -v -X POST -F '[email protected]&password=my_password' https://myurl.com/login
    

    Your Laravel application may be set up to only accept POST requests to the /login endpoint if you continue to receive a 405 Method Not Allowed error. To send a GET request in this situation, you must use the -X GET option.

    curl -X GET -F '[email protected]&password=my_password' https://myurl.com/login
    

    Please check these things. It’s helpful.

    Login or Signup to reply.
  2. do you have this RewriteRule ^ %1 [L,R=302] in your htaccess? if so, try to change it to RewriteRule ^ %1 [L,R=307]and see if it works or not.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search