# |
Apr 19th 2017, 15:38 |
Neon1024 |
So I can bin requests to my api if they don’t authenticate, without even leaving the middleware stack! :D |
# |
Apr 19th 2017, 15:38 |
Neon1024 |
I’ve also implemented the cakephp/authentication middleware in a branch |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
Everything. You don’t get a choice:p |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
As everything on my /api prefix will be json |
# |
Apr 19th 2017, 15:37 |
Neon1024 |
Well I do that in my middleware |
# |
Apr 19th 2017, 15:35 |
crazycoder |
oh better i set application/json |
# |
Apr 19th 2017, 15:35 |
crazycoder |
right ? |
# |
Apr 19th 2017, 15:35 |
crazycoder |
Neon1024, yes i should check if json...if yes i will skip that line |
# |
Apr 19th 2017, 15:35 |
Neon1024 |
Well there you are! |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
https://gist.github.com/anonymous/f23de065af63b1388b64bd8332bdf031#file-gistfile1-txt-L29 |
# |
Apr 19th 2017, 15:34 |
crazycoder |
Neon1024, https://gist.github.com/anonymous/f23de065af63b1388b64bd8332bdf031 |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Perhaps you renderer is always assuming html |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
Then perhaps that could be why |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
As I think it’s supposed to pick a layout and template to match the extension |
# |
Apr 19th 2017, 15:34 |
crazycoder |
i am using a custom renderer ( i do not remember the reason ) :D |
# |
Apr 19th 2017, 15:34 |
Neon1024 |
It’s the _outputMessage() method which confused me |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
Then changed the array data to match the json I wanted |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
if ($this->controller->request->is('json') andand strpos($this->controller->request->url, "api/v4") !== false) { |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
In the render() method I jsut added |
# |
Apr 19th 2017, 15:33 |
Neon1024 |
I ended up copying it and just changing it a little to suit my needs |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
I found the code in the ExceptionRenderer hard to follow |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, yes |
# |
Apr 19th 2017, 15:32 |
Neon1024 |
Hm, then perhaps it’s not hitting the controller action. Maybe the exception renderer doesn’t care about the headers and responds as html anyway |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ^ |
# |
Apr 19th 2017, 15:32 |
crazycoder |
Neon1024, ? |
# |
Apr 19th 2017, 15:32 |
crazycoder |
no for not existant actions |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
^ For your incorrect url I mean |
# |
Apr 19th 2017, 15:31 |
Neon1024 |
crazycoder: So if you use postman, and send a Content-Type: application/json header do you get a json error back? |
# |
Apr 19th 2017, 15:31 |
admad |
Erik: missing use statement |
# |
Apr 19th 2017, 15:30 |
crazycoder |
(yes i am using postman) |
# |
Apr 19th 2017, 15:30 |
crazycoder |
if i call an existant action i can work without XMLHttpRequest too |
# |
Apr 19th 2017, 15:30 |
crazycoder |
Neon1024, strange thing... if i do /api/notexists i will get an html output |
# |
Apr 19th 2017, 15:30 |
Erik180486 |
Cake\Event\Event given, called in /vendor/cakephp/cakephp/src/Event/EventManager.php |
# |
Apr 19th 2017, 15:29 |
Erik180486 |
anyone has any idea what this error means: Argument 1 passed to App\Controller\UsersController::beforeFilter() must be an instance of App\Controller\Event, instance of |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
https://www.getpostman.com/ |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
I’d hit stuff with Postman to check the api at least |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Your setup sounds okay to me |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
As XMLHttpRequest isnt’ supported in Internet Explorer or something like that |
# |
Apr 19th 2017, 15:28 |
Neon1024 |
Oh, are you not wrapping the Javascript in something? |
# |
Apr 19th 2017, 15:25 |
crazycoder |
Neon1024, ^^ |
# |
Apr 19th 2017, 15:24 |
crazycoder |
then i have seen that if i do not use XMLHttpRequest the component does not get the request....! |