Requests received as GET rather than POST - grimpirate - 11-20-2020
Planning to use CodeIgniter to set up an intermediary API. Following the instructions from Heroku and Code Igniter I performed the following steps:
- Created an empty directory and traversed into it
- composer create-project codeigniter4/appstarter --no-dev
- Removed unneeded files/directories (tests/ Home.php view_message.php .github/)
- Modified .env to have the following: CI_ENVIRONMENT = production, app.baseURL = 'https://my-app-99999.herokuapp.com/', and finally app.CSRFProtection = false
- Modified App.php to have public $baseURL = 'https://my-app-99999.herokuapp.com/'; and public $indexPage = '';
- Modified Routes.php to not have a default controller and setAutoRoute(false) also removed the default route and instead $routes->resource('token')
- Created Token.php controller which extends ResourceController with create() method no index() method wherein create method does the following: return $this->respond($this->request->getPost());
- Create a Procfile with web: vendor/bin/heroku-php-apache2 public/
- git init followed by git add and git commit and finally heroku git:remote -a my-app-99999
- git heroku push master
So basically I'm trying to construct a simple test case which responds to a post on my-app-99999.herokuapp.com/token/. However, when using Postman to to send a post request to the URL I receive back a 501 json message that indicates that "index" action not implemented. Why is the request to that URL being interpreted as a get rather than a post? I know this works as expected because if I run php spark serve I get the post array returned when I use Postman at localhost:8080/token. What's causing the problem on the web side?
|