Closed Ali-Javanmardi closed 2 months ago
The cors
middleware never returns method-not-allowed. It also doesn't set the Allow
header (what it does set is the Access-Control-Request-Method
header).
It sounds like you are having problems with the axum routing setup. Please use axum's Q&A section, and post your full routing setup.
Bug Report
Version
tower-http = 0.5.2 axum = 0.7
Platform
Linux U41-DEV 6.9.4-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 12 Jun 2024 20:17:17 +0000 x86_64 GNU/Linux
Crates
Description
My post request to axum server gets cors error "405 Method Not Allowed"
My axum server is running on http://localhost:8080 My front-end app (vuejs) is running on http://localhost:5173
my axum server should work as an api server.
First I read this example: https://github.com/tokio-rs/axum/blob/main/examples/cors/src/main.rs so I added CorsLayer to my routes in axum routes.
Even after that I got the error above. I tried to add all possible request methods to this CorsLayer but there were no success. I changed it to "Any" but nothing changed.![Screenshot_20240618_012337](https://github.com/tower-rs/tower-http/assets/5300198/acf8ab18-e99b-477c-adf6-2af26cd9ade2)
Here is my code:
Please let me know if I'm doing something wrong.