0

I am trying to build a test app with a vue frontend and a spring boot backend. The backend receive a json from the frontend to register a new user.

But I am struggeling at the point to send a post request from the vue frontend to the backend. I only receive the status Blocked.

So this is the method in vue which should send the post request:

testMethodToClick() {
    const data = {
        "firstName": "Test",
        "lastName": "Tester",
        "email": "test.tester@test.de",
        "password": "password"
    }

    const header = {
        "Content-Type": "application/json",
        "Accept": "*/*"
    }

    axios.post("http://ptsv2.com/t/ty0mk-1643012780/post");
    axios.post("http://localhost:8886/api/v1/registration", data, header);
}

The first post request to ptsv2.com is just to test if the post request generally is working.

But this is the result:

enter image description here

But if I try to test the endpoint with postman, than it works:

enter image description here

So I did something wrong on the vue side. Does someone know what I am missing?

Thank you very much!

Michael
  • 313
  • 1
  • 4
  • 10
  • 1
    Does this answer your question? [XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header](https://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-xxx-no-access-control-allow-origin-header) – Quentin Jan 24 '22 at 09:32
  • Open the developer tools console. Read the error messages. It should tell you what CORS related error you have. – Quentin Jan 24 '22 at 09:32
  • 1
    I think your Backend is not allowing Cross-Origin-Requests. You will need to allow that: https://spring.io/guides/gs/rest-service-cors/ – dominikjosch Jan 24 '22 at 09:39

0 Answers0