4

while trying to access http:Localhost:9000/api/post from provider i get this error

Failed to load http://127.0.0.1:8000/api/post: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. is therefore not allowed access

any knows what is wrong.

zainudin noori
  • 191
  • 4
  • 12
  • looks like it is server configuration issue, not angular, you must setup 'CORS' configuraion on your server side – happyZZR1400 Mar 04 '18 at 10:06
  • Apache HTTP Server – zainudin noori Mar 04 '18 at 10:08
  • 6
    Possible duplicate of [No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '...' is therefore not allowed access](https://stackoverflow.com/questions/20433655/no-access-control-allow-origin-header-is-present-on-the-requested-resource-or) – brk Mar 04 '18 at 10:08
  • @brk I didn't get any solution from those. – zainudin noori Mar 04 '18 at 10:10
  • @zainudinnoori Please read the dup post again, your answer is included in the answers on the linked dup. – Teemu Mar 04 '18 at 10:14
  • may be this link can be usefull:https://gist.github.com/technoknol/1a35ca4b150215f491d5c807940bd4ef – happyZZR1400 Mar 04 '18 at 10:15

1 Answers1

1

Your front and back end are on different ports which means your ajax requests are subject to cross origin security.

You need to do changes at your back-end api (server side) by adding

Access-Control-Allow-Origin: "*";

in response headers according to the language you are using php,java or python e.t.c.