laravel / precognition

Anticipate the outcome of a future HTTP request.
https://laravel.com/docs/precognition
MIT License
132 stars 32 forks source link

Precognition is not working for the specified route #87

Closed siarheipashkevich closed 2 months ago

siarheipashkevich commented 2 months ago

Laravel Precognition Plugin Version

0.5.6

Laravel Version

11.19.0

Plugin

React

Description

I'm trying to play with your package and want to decide to use it or not.

But I'm facing with some not obvious issues which not documented: 1) We should add precognition and precognition-success headers to exposed_headers property in cors.php file 2) I want to specify HandlePrecognitiveRequests middleware to the specific route of my controller (store method):

image

But it's not workin and I'm getting an error on the front-end side:

image

What am I doing wrong?

Steps To Reproduce

Please see description above.

Thanks

driesvints commented 2 months ago

We'd welcome a PR to the docs for the firs issue. For the second one I kindly redirect you to a support channel:

siarheipashkevich commented 2 months ago

@timacdonald could you please take a look at the second issue?

I think there is a really problem, I also tried to add options route but nothing.

timacdonald commented 2 months ago

@siarheipashkevich, I'm unable to reproduce the issue you are hitting with a fresh Laravel application. Could you provide a minimal reproduction repository?

siarheipashkevich commented 2 months ago

@timacdonald sorry, it's my fault. Take a look at my only parameter which is wrong.. I should declare store not post ((

timacdonald commented 2 months ago

ahhh! Gotcha. Easily done.

Dop you think the CORS issue is still a problem or was it just the only parameter that was the issue?

siarheipashkevich commented 2 months ago

I think it's still an issue. Because it's not obvious right now. Yes, we have mention about Precognition header in the documentation, but nothing about Precognition-Success etc

And I think will be better to notice about this if the Laravel used as API with cors configurations.

Thanks for your answers and attemptings to make Laravel packages better!