Comments (21)
哈哈,我是这样做的
from laravel-s.
是否使用的PHP原生header()
函数?
不能使用的函数
from laravel-s.
@hhxsv5 我看了 那个包没有使用原生的header()
from laravel-s.
第三方包吗?文件发下。
from laravel-s.
@hhxsv5 https://github.com/palanik/lumen-cors
from laravel-s.
from laravel-s.
from laravel-s.
from laravel-s.
body数据都正常吗?怀疑代码没走到中间件。
from laravel-s.
@barretzhi 细聊 QQ群:698480528
from laravel-s.
body 正常的,我也在怀疑没走到中间件。 我发现服务启动后bootstarp/app.php 下的文件在每次请求的时候都不走
from laravel-s.
Dingo Api中干掉了Application的全局中间件。
https://github.com/dingo/api/blob/master/src/Routing/Adapter/Lumen.php#L253
目前还没有较好的办法解决,我再想想看
from laravel-s.
好的,谢谢
from laravel-s.
不用中间件实现CORS
,直接Response对象带上Header吧。这是目前较理想的解决方案。
public function index(Request $req)
{
$headers = [
'Access-Control-Allow-Origin' => '*',
//...
];
$data = ['now' => time()];
return response()->json($data, 200, $headers);
}
然后,再统一封装一个Trait
来做响应。
from laravel-s.
跨域问题可以用nginx解决,这样又快又不需要引入那个包
from laravel-s.
@dickwu 也不错
from laravel-s.
Problem solved partially, at least by now. Here is the solution:
Coding @ config/laravels.php as follows:
'register_providers' => [
/* middleware service providers */
Dingo\Api\Provider\DingoServiceProvider::class,
Dingo\Api\Provider\HttpServiceProvider::class,
/* auth service providers */
Illuminate\Auth\AuthServiceProvider::class,
App\Providers\AuthServiceProvider::class,
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
],
Git it a try, and wish it would work for you, too.
from laravel-s.
from laravel-s.
目前还是不支持dingo吗?
from laravel-s.
@FlameMida 是的
from laravel-s.
我这也是请求一段时间就报跨域错误,没用djingo。用的\Medz\Cors\Laravel\Middleware\ShouldGroup中间件.求大佬帮忙,卡了2,3天了。
from laravel-s.
Related Issues (20)
- 请问如果使用的Sanctum 轻量级 API 认证,第二次通过request->user()结果为null 这么配置解决? HOT 2
- 请问 laravel/sanctum 怎么正确使用在laravel-s 项目上 HOT 7
- 请问如何启动服务时仅开启ws服务 HOT 2
- 系统偶发报connect() to unix:/dev/shm/live-server.sock failed HOT 6
- 开启了自定义进程process, 使用laravels stop命令不能关闭服务器 HOT 2
- nginx代理后怎么获取客户端真实IP呢? HOT 2
- Telescope 请求跟踪问题 HOT 1
- does not exist, or permission denied HOT 1
- `App\Console\Commands`下的创建的自定义命令中调用`app('swoole')`显示`Target class [swoole] does not exist`. HOT 2
- [QUESTION] quit property on custom process during reload
- 我使用这个只使用ws服务,其他业务使用了fpm模式,发现一个问题 HOT 1
- tcp socket onConnect 里面能使用数据库模型,onReceive 不能使用,啥原因 HOT 1
- Target class [swoole] does not exist error in console command with laravels server start and up HOT 2
- dcat-admin使用问题 HOT 1
- LaravelS 3.7.37 Optimized the call of schedule:run command Issue HOT 1
- 配置项 `register_providers` 不生效 HOT 2
- 启动的工作目录问题 HOT 1
- The operation of websockets and dispatch_mode HOT 3
- laravels master 内存没释放 HOT 2
- Response time increases possible memory leaks HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-s.