symfony / stimulus-bridge

Stimulus integration bridge for Symfony projects
https://symfony.com/ux
75 stars 15 forks source link

symfony+easyadmin+api platform+ux-react about session #80

Closed langziyang closed 1 year ago

langziyang commented 1 year ago

my proejct use easyadmin and ux-react get api platform endpoing, this is my api platform new GetCollection( security: 'is_granted("IS_AUTHENTICATED_FULLY")' ) on my easyadmin DashboardController:

`

[Route('/admin', name: 'admin.dashboard')]

public function index(): Response { return $this->render('admin/dashboard.html.twig'); } admin/dashboard.html.twig: <div {{ react_component('MemberList') }}>

`

MemberList.jsx

useEffect(() => { axios.get('http://192.168.100.100:8003/api/members?page=1').then(resp=>{ console.log(resp) }) }, []) then ,i get Access Denied error.

i am sure i alread login on /admin router

weaverryan commented 1 year ago

Hi!

Do you need the withCredentials setting in axios? Anyways, if you log in and are using a session, your Ajax requests should be able to use that session as well. That is just normal session + cookie + Ajax behavior :). It’s independent of api platform, stimulus, and ux-react.

good luck!