Hello, I’m working with my RESTapi now over HTTP, but I would like some routes (e.g. authentication) be HTTPS for security issues. How should I do it?
Here you can see the structure of the route:
@robrothedev Thanks for your reply, and if you don’t mind, I would like to make some more questions.
so there is nothing to do with Slim at all?
And for example, using the configuration that your provided, if I use AJAX for authentication making request to http://myapp.com/api/auth (as usual), it will work over HTTPS and thus protecting the credentials I sent as post data? Or I have to use https://myapp.com/api/auth?
@robrothedev Thank you for all the information.
Just want to make things clearer. I’m debugging with WAMP (without HTTPS enables), and used the configuration you mentioned, and when I send a GET request with Postman: http://myapp.com/api/xxx, I got Internal Server Error, so I think it’s mandatory to use https://myapp.com/api/xxx?
@Antnee Hi, thanks for your reply.
But I have some (maybe silly) questions:
If I use redirection method, and I post data with HTTP at first, wouldn’t it be unsafe?
As you said, if it’s not HTTPS request then redirect (via 303) to the HTTPS version. What should I do for implementing the HTTPS version if I have the HTTP version as follow?
I have a similar problem to ywy9876, and I have recently setup my remote LAMP server with SSL which works fine with slim. However I get 504 gateway time out error on my routes that connect to mysql. My routes work fine when the same index.php file is on my local XAMPP server (which is not SSL enabled). So it appears to me that the https protocol is not yet working. what you said here seems to be a great solution, but I don’t know where to begin with middleware. Any help appreciated. Thanks