Nov 5, 2021
0
Level 1
Laravel Jetstream | Inertia - has been blocked by CORS policy
I'm working with forms in inertia its working fine with using GET and POST request. but when it came into PUT/PATCH or DELETE i got a error saying:
Access to XMLHttpRequest at 'http://localhost:8000/admin/cms/sections' (redirected from 'http://localhost:3000/admin/cms/sections/9') from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
here is the code on my controller
public function destroy(Section $section)
{
$section->delete();
$message = "Section <strong class='text-green-700'>".$section->title ."</strong> has been deleted";
return redirect()->route('admin.cms.sections.index')->with('success', $message);
}
and here the code in my vue file
import { useForm } from "@inertiajs/inertia-vue3";
const form = useForm({
is_published: null,
});
const onDelete = (data) => {
form.delete(route("admin.cms.sections.destroy", data));
};
Please or to participate in this conversation.