lawliet89/rocket_cors

Fairing working in local but not in remote server

alexislozano opened this issue · 1 comments

Hello and first of all thanks for rocket_cors !

I use rocket_cors ver. 0.5.2.
My rocket application has an auth/signin route.
Here is my main function :

fn main() {
    let cors = rocket_cors::CorsOptions::default().to_cors();

    match cors {
        Ok(cors) => {
            EnvironmentImpl::check();
            let mut rocket = rocket::ignite().manage(db::init_pool()).attach(cors);
            rocket = auth::mount(rocket);
            rocket = health::mount(rocket);
            rocket.launch();
        },
        Err(e) => panic!(e) 
    }
}

When I call it using a frontend app I am developping, it works as expected in local (front on localhost:8080, back on localhost:8000):

🚀 Rocket has launched from http://localhost:8000
OPTIONS /auth/signin:
    => Error: No matching routes for OPTIONS /auth/signin.
    => Warning: Responding with 404 Not Found catcher.
    => CORS Fairing: Turned missing route OPTIONS /auth/signin into an OPTIONS pre-flight request
    => Response succeeded.
POST /auth/signin application/json:
    => Matched: POST /auth/signin (signin)
    => Outcome: Failure
    => Warning: Responding with 404 Not Found catcher.
    => Response succeeded.

Screenshot_20200321_162544
Here 404 on POST in normal because I entered random characters in the fields. OPTIONS response being 204 is great !

But when I push my backend to my vps (in a docker container behind an nginx proxy), the server answers a 404 status code to the OPTIONS request (I tried with the front app located on the vps and with the front app located on localhost:8080) :

2020-03-21T15:09:55.872960036Z Rocket has launched from http://0.0.0.0:8000
2020-03-21T15:10:30.013654968Z Error: No matching routes for OPTIONS /auth/signin.
2020-03-21T15:10:30.014170708Z Warning: Responding with 404 Not Found catcher.

Screenshot_20200321_162430
As you can see OPTIONS responds 404 instead of 204 as before...

Note that a POST request sent to the remote server using Postman works.

Here is the url of the front-end app if you want to try and see the request :
https://app-dev.kobumi.com/#/login

I worked a bit on my server today. Actually, I forgot to put 0.0.0.0 as the rocket address so the server was not reachable from out of the docker container. My mistake then :)