I recently did a small project, using Vue + Thinkphp6, the local development environment was tested through vue. Config. js, but there was no problem.

Especially thanks to the Nuggets’ DailC article ajax cross domain, this should be the most complete solution out there.

If you have similar problems you can read the above article in detail to help.

Thinkphp6 allows OPTIONS requests to be initialized in app -> BaseController.

The code is as follows:

// initialize protectedfunction initialize() {// allow OPTIONS requestsif(Request::method() == 'OPTIONS'){
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
        header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
        exit();
    }
}
Copy the code