Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve Cross-domain problems through Global Middleware in thinkphp6

Shulou Source: shulou.com Published: 2022-06-03 10:43:15 11月15日 Update

This article will explain in detail how thinkphp6 solves cross-domain problems through global middleware. The content of the article is of high quality, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

TP6 solves cross-domain problems through global middleware

Tp6 official website provides cross-domain resolution method, when I directly use can not be used. (Maybe I'm using the wrong posture.)

The frontend sends ajax requests in Hbuildert, which occurs across domains.

Get request: can be resolved through background settings. 'Access-Control-Allow-Origin: *'。post request: An OPTIONS request occurs. Add a header to the ajax request. header:{ 'Content-Type':'application/x-www-form-urlencoded'} Define middleware

Tags: Middleware overall situation problem content article more knowledge article no not bad information front end can pass background easy to use posture method quality China plus reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology MySQL Docker macOS OPPO Reno