Closed crapthings closed 8 years ago
To customize resumable, you need to create your own resumable instance, rather than using the one automatically provided on the client.
It's easy, just use the code for the default implementation as a reference: https://github.com/vsivsi/meteor-file-collection/blob/master/src/resumable_client.coffee#L28-L46
i can find key, but there's no value found in req.headers
'access-control-request-headers': 'origin, content-type, x-cube-token, x-auth-token',
it's working on desktop browser
not work with cordova preflight request, like above only key that i can find in 'access-control-request-headers'
after add "a custom key string" to preflight options
'Access-Control-Allow-Headers': 'x-auth-token, user-agent, x-cube-token',
it works
but the if i remove x-cube-token(a custom header)
i can't get x-auth-token too, its weird
'Access-Control-Allow-Headers': 'x-auth-token, user-agent',
failed to get x-auth-token from cordova
now everything works fine!!!
@crapthings your reply is so helpfull, could you tell me how to make that works fine. we handle auth with cordova but handle_auth always return null
`handle_auth = (req, res, next) -> unless req.meteorUserId?
if req.headers?['x-auth-token']?
req.meteorUserId = lookup_userId_by_token req.headers['x-auth-token']
# Or as a URL query of the same name
else if req.cookies?['X-Auth-Token']?
req.meteorUserId = lookup_userId_by_token req.cookies['X-Auth-Token']
else
req.meteorUserId = null`
等我有电脑的
@crapthings 谢谢啊,路过济南或者上海我请客 有想在济南做meteor开发的小伙伴欢迎推荐
@crapthings
Documents.resumable.defaults.headers = { 'x-auth-token': Accounts._storedLoginToken() }
'Access-Control-Allow-Headers': 'x-auth-token, user-agent',
http post 方法可以正常获取 x-auth-token,cordova 下http options 还是取不到 x-auth-token,貌似resumable.defaults.headers 没有影响到 options 方法,或者是因为options方法是由浏览器触发的,所以使用的不是 resumable的header???
求教!
Documents.resumable
这下边有个叫 opt还是opts 的对象,实际在这里写
Documents.resumable.opt.headers = { test: 1 }
后边就能抓到了
用了opts的设置,post 时可以抓到,options还是不行,估计是因为options是浏览器触发的原因吧
i've set these code before resumable.upload(), but there's nothing in req.headers
Documents.resumable.defaults.headers = { 'x-auth-token': Accounts._storedLoginToken() }
Documents.resumable.withCredentials = true