Target class [App\\Http\\EnsureFrontendRequestsAreStateful] does not exist - reactjs

I am using Laravel Sanctum to authenticate a react SPA with a laravel API backend.
While I am trying to access routes which does not need authentication, I am getting this error:
"Target class [App\Http\EnsureFrontendRequestsAreStateful] does not exist."
What should I do to guard only some routes, while leaving others open.

You are probably missing the import in the app/Http/Kernel.php file.
// app/Http/Kernel.php
<?php
namespace App\Http;
use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful;

This can usually be solved with: composer dump-autoload
You can read more about what the command does here
composer dump-autoload won’t download a thing. It just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). Ideal for when you have a new class inside your project.

Related

Unable to mount actionable to routes

I am trying to add ActionCable to my routes.
One guide says to do:
/config/routes.rb
...
mount ActionCable.server = '/cable'
...
However when I try to do so and run rails routes, I get the following error:
undefined method server=' for ActionCable:Module (NoMethodError) Did you mean? server
I have tried looking for an answer to this however I couldn't find anything.
I am trying to do a React - Ruby on Rails class project.
Wondering if the syntax changed with rails versions. In the Rails Guides (which you should be using), it states to use mount in the application.rb file
class Application < Rails::Application
config.action_cable.mount_path = '/websocket'
end

MDbootstrap materialSelect is not a function Rails and Webpacker app

Im trying to figure out why the function materialSelect() is doesn't exist in the app context.
The MDboostrap select field is created correct with behaviour and style but I am trying to destroy and re-initialize using materialSelect() such as:
const $select = $('.mdb-select');
$select.materialSelect({destroy: true});
$select.materialSelect();
I get the follow error:
materialSelect is not a function
This app uses Rails 6/Webpacker. I think there is a file missing here since this app was created without the min.js file, instead each mdbootrap dependency was downloaded and added to the project.
The reason why this is not working is because of the MDBoostrap version. This project uses 2.2.1 and materialSelect() doesn't exist under this version. I was able to get it working on latest version 4.20.0

Partially Shifting to react from Django

Basically I have a project in Django, in all it has 7 apps. I want to shift one of them in react.
Say app 'Student' is the one which I want in React. I want to know if its possible to do so, if yes then how?
Here is what I tried, I created a react project and using npm run build command I got a build of that react project.
Now for base url of Student i rendered template which was in react build folder.
Something like this.
urls.py
urlpatterns = [
...
...
path('student/', views.Student, name='student'),
....
]
views.py
def Student(request):
return render(request, 'build/index.html')
Where index.html is the file present in build folder.
Using this approach i was able to render the react template but the other url routes were not working.
Please let me know what's wrong in this approach, if this approach is wrong then do suggest another approach.
It's possible to do that. It has been explained extensively in this tutorial.

How do I configure Flow in a newly created React JS app?

After creating a new React app with create-react-app, there is no .flowconfig file. If I flow at command line, I get:
Could not find a .flowconfig in . or any of its parent directories.
See "flow init --help" for more info
If I do a flow init, it'll create a .flowconfig file, but with no default configuration:
[ignore]
[include]
[libs]
[options]
This seems to be all that I need to do to get flow working. In contrast, a newly created React Native app has a .flowconfig file with a lot of "default" configuration.
Is there a recommended default configuration for a React JS environment?
I don’t know much about React Native, but indeed this should be all that’s necessary to get Flow working with an app generated by Create React App. Of course you’ll also need to add // #flow to the files in which you want Flow to be enabled.
See also “Adding Flow” in the User Guide.

Include sitemap in cakephp

I generated a normal sitemap with an online Sitemalgenerator:
http://xml-sitemaps.com
Now I tried to include it like every other Sitemap on a Server.
The problem is, on this Server seems to be a CakePHP Framework and I dont know, how it works cause
I dont have any experience in PHP.
The error:
Missing Controller
Error: Sitemap.xmlController could not be found.
Error: Create the class Sitemap.xmlController below in file: app/Controller/Sitemap.xmlController.php
<?php
class Sitemap.xmlController extends AppController {
}
Can you tell me, how to include a XML Sitemap in the easiest way? I'm a beginner in Webprogramming!
(I dont want to create a dynamic Sitemap)
Thank you!
Place your file in your webroot folder:
app/webroot/Sitemap.xml
As long as the file is found in the webroot CakePHP will load it, if the file is not found it will run through its normal application request cycle based on your defined routes.

Resources