Thinkphp6如何跨域请求
2023-03-29 23:03:03
142
{{single.collect_count}}

1.在Thinkphp6如果某个路由或者分组需要支持跨域请求,可以使用

Route::get('new/:id', 'News/read')
    ->ext('html')
    ->allowCrossDomain();

跨域请求一般会发送一条OPTIONS的请求,一旦设置了跨域请求的话,不需要自己定义OPTIONS请求的路由,系统会自动加上。 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}