No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    CORS Preflight Did Not Succeed with axios authentication

    Framework
    2
    4
    2393
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      Incremental last edited by Incremental

      Hello, I’m having a weird problem using October’s JWT and CORS plugins :

      [https://octobercms.com/plugin/offline-cors]
      [https://octobercms.com/plugin/vdomah-jwtauth]

      And I’m now searching since a long time…

      The strange thing is that it is only working with the sample “test” route, it’s working fine with authentication but as I change the name to another route ie: “Change-Pwd”,
      in Firefox console I get : “CORS Preflight Did Not Succeed” and “Cross-Origin Request Blocked”
      The detailed info in the console show a wrong referer. Is there something to indicate in axios ?
      CORS has “Allowed origins”:, “Allowed headers”:

      Thanks for your help.
      bf2d7b55-146c-454a-b112-722c82599c24-image.png

      44e5a62b-49b0-4ed3-8358-2259f56adc79-image.png

      Here is my axios call :

      changePassword({ commit }, pwd) {
      	const config = { headers: { Authorization: "Bearer " + state.token } };
      	return ( axiosInstance
      			.post(constantes.SERVER_URL + "/Change-Pwd", pwd.data, config)
      			.then((response) => {
      				Notify.create({ message: "Pwd changed OK !", color: "green", textColor: "white", icon: "thumb_up" });
      				if (state.redirectURL) {
      					if (this.$router.currentRoute.path !== state.redirectURL) setTimeout(() => this.$router.push(state.redirectURL), 3000);
      				}
      			})
      			.catch((error) => {
      				let errors = errorMgt(commit, error, { consoleLog: true });
      				throw error;
      			})
      	);
      },
      
      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @Incremental last edited by

        @incremental said in CORS Preflight Did Not Succeed with axios authentication:

        The strange thing is that it is only working with the sample “test” route, it’s working fine with authentication but as I change the name to another route ie: “Change-Pwd”,

        How I read is this: cors request work fine except for your new Change-Pwd route, all other request work fine( auth & test).

        What happens when you just browse to Change-Pwd. Does this route work at all? ( 404?)

        If it does work what happens when you change Change-Pwd to foobar (no capitals ect , look semantically more like test)

        What happens in chrome?

        Here’s a tool that helps to debug cors request:
        https://www.test-cors.org/

        I 1 Reply Last reply Reply Quote 0
        • I
          Incremental @dobbel last edited by Incremental

          @dobbel well I have a web ‘test’ page, that’s why I’m getting the response (with authentication or not).
          By the way, I always get a 404 for any other routes. I have to check the problem in the PHP server routes…

          Same problem with ‘foobar’
          As my Quasar page is named ‘Test’, it’s probably why Referer = http://localhost:8080/test

          Same problem with Chrome :
          9f97c99e-967e-47e5-86ce-0d01deccd5ff-image.png
          I have to test Debug Cors…

          1 Reply Last reply Reply Quote 0
          • I
            Incremental last edited by Incremental

            Finally, the problem was in October CORS plugin.
            It worked with the following code added to my route.php :

            Route::options('/{any}', function() {
                $headers = [
                    //'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
                    'Access-Control-Allow-Headers'=> 'X-Requested-With, Content-Type, X-Auth-Token, Origin, Authorization'
                ];
                return \Response::make('You are connected to the API', 200, $headers);
            })->where('any', '.*');
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post