Struggling with Laravel: Removing Vite and CSRF Tokens

0
10
Asked By CuriousMonkey93 On

I've just dived into Laravel, and I'm facing some challenges. First off, I had a tough time figuring out why Vite is included in Laravel by default. I heard that you can write views in React—does this mean that using JSX with Blade is possible? If not, can I keep them completely separate in their own folders?

Right now, my major issue is trying to remove the CSRF token from cookies since my project doesn't have any APIs, and I believe I don't need them. I thought removing it would be an easy config change, but it's been trickier than anticipated. Plus, once I get that sorted, I'm hoping to set the SameSite attribute to strict rather than lax. Any suggestions?

6 Answers

Answered By ReactFan22 On

Just so you know, Vite is a popular choice for working with React projects. It's included with Laravel to support modern front-end workflows, but you can certainly separate React if that's your style. Glad to hear you figured out how to remove it!

Answered By FrameworkFanatic45 On

Laravel is hands down my favorite framework, period! But hey, if it makes you feel better to blame your learning curve on the framework, that's up to you.

CuriousMonkey93 -

What do you mean by 'hands down'? Is that just your opinion, or is there an objective reason for it?

LogicMaster10 -

Is there even a config option to just turn off CSRF cookies?

Answered By DevGuru77 On

Honestly, if you don't plan on having an API, you might want to reconsider using Laravel altogether. It’s an amazing framework, but it shines with full stack applications.

CuriousMonkey93 -

I thought it would still help with user input validation and role-based authorization. Doesn't Laravel offer those features easily?

CodeMaster99 -

As opposed to what other frameworks?

Answered By DocNerd32 On

It sounds like you might benefit from some deeper reading of the documentation. It can really help clarify things about CSRF and other configurations you’re struggling with.

CuriousMonkey93 -

I’ve looked through docs, videos, and even tried using AI for assistance, but I’m still stuck.

Answered By TechWizard21 On

Make sure to choose the right starter kit for your Laravel project. Sometimes, going with a different setup can streamline your experience from the get-go!

Answered By CodeLover18 On

Check out these links on how to disable the CSRF middleware if you’re looking to adjust that. You might find some insights in the code examples provided. Here's one link: [GitHub example](https://github.com/search?q=+%3EwithoutMiddleware+language%3APHP+csrf&type=code) and [Laravel docs](https://laravel.com/docs/12.x/middleware#excluding-middleware).

CuriousMonkey93 -

I'm not looking to exclude it; I want to completely disable the cookies. I might have to extend the default classes to achieve that.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.