-3

My vue script like this :

<script>
export default {
    ...
    methods : {
        login() {
            // uri -> http://my-app.test/login?email=test@gmail.com&password=1234
            this.axios.get(uri).then((response) => {
                console.log(response)
                ...
            },
            ...
        }
    }
}
</script>

When login method executed, on the console exist error like this :

Failed to load http://my-app.test/login?email=test@gmail.com&password=1234: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

How can I solve the error?

moses toh
  • 12,344
  • 71
  • 243
  • 443
  • @Quentin I still don't find an answer there – moses toh Sep 06 '18 at 08:01
  • 2
    The answer is, make sure that the endpoint you are trying to reach is sending a fitting `Access-Control-Allow-Origin` header – Luca Kiebel Sep 06 '18 at 08:03
  • @Luca Kiebel I need a specific answer – moses toh Sep 06 '18 at 08:09
  • 1
    Nope, you really don't. Answer these questions for yourself: What endpoint are you trying to reach? What headers should it send, but evidently isn't? What can you do about it? – Luca Kiebel Sep 06 '18 at 08:10
  • @SuccessMan — If by "specific answer" you mean "a lump of code you can copy/paste" then we can't give that to you. We know nothing about the server side code generating the data you are requesting. – Quentin Sep 06 '18 at 08:16
  • @Mihai — There's no need to answer in the comments. If you think you can provide a better answer than the ones on the duplicate question, then answer there. (Note that the OP has not mentioneed PHP anywhere in their question). – Quentin Sep 06 '18 at 16:09

1 Answers1

-2

You have to read about CORS in order to understand how you can share resources between two websites.

Luca Kiebel
  • 9,790
  • 7
  • 29
  • 44
Deepak gupta
  • 504
  • 1
  • 6
  • 22