You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "rahulreghunath (via GitHub)" <gi...@apache.org> on 2023/02/27 10:36:41 UTC
[GitHub] [apisix] rahulreghunath opened a new issue, #8955: bug: Cors Plugin not working when request having authorization token
rahulreghunath opened a new issue, #8955:
URL: https://github.com/apache/apisix/issues/8955
### Current Behavior
```
{
"uri": "/api/v0/s1/*",
"name": "route-subscriber",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH"
],
"plugins": {
"cors": {
"allow_credential": true,
"allow_headers": "**",
"allow_methods": "**",
"allow_origins": "http://localhost:5173",
"disable": false,
"expose_headers": "**",
"max_age": -1
}
},
"upstream_id": "1",
"status": 1
}
```
above is the route configuration which I am using, but with this configuration, I am still getting the CORS error only when the request contains an authorization token.

above is the request header of the failed request and below is the response from API for the request without token

### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
run api six via docker image
write a sample vue application which can sent a server request
configure cors plugin as mentioned above
sent a request with an authorization token
### Environment
- APISIX version apisix:3.0.0
- Operating system ubuntu 20
- etcd version, etcd:3.4.15
- APISIX Dashboard version apisix-dashboard:2.13-alpine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] mscb402 commented on issue #8955: bug: Cors Plugin not working when request having authorization token
Posted by "mscb402 (via GitHub)" <gi...@apache.org>.
mscb402 commented on issue #8955:
URL: https://github.com/apache/apisix/issues/8955#issuecomment-1447665063
I think you may need to add `withCredentials` to your front-end request. https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
If you are using axios for send request, you can try
```
const myrequests = axios.create({
withCredentials: true,
...
})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Cors Plugin not working when request having authorization token [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8955:
URL: https://github.com/apache/apisix/issues/8955#issuecomment-1941024954
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Cors Plugin not working when request having authorization token [apisix]
Posted by "rahulreghunath (via GitHub)" <gi...@apache.org>.
rahulreghunath commented on issue #8955:
URL: https://github.com/apache/apisix/issues/8955#issuecomment-1962435327
The actual issue was with the preflight request. The preflight request was not handled properly. Since the preflight did not contain credentials, it was returned with status code 401 which caused the CORS error. I have handled this case separately in the runner.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Cors Plugin not working when request having authorization token [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8955:
URL: https://github.com/apache/apisix/issues/8955#issuecomment-2646157498
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Cors Plugin not working when request having authorization token [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #8955: bug: Cors Plugin not working when request having authorization token
URL: https://github.com/apache/apisix/issues/8955
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] bug: Cors Plugin not working when request having authorization token [apisix]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8955:
URL: https://github.com/apache/apisix/issues/8955#issuecomment-2676751389
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org