0

I have an app in plain html file (no server). How do I do cross domain requests (from javascript)?

Browser reports error: XMLHttpRequest cannot load '*'. No 'Access-Control-Allow-Origin' header is present on the requested resource.

I tried the following, but no dice.

<meta http-equiv="Access-Control-Allow-Origin" content="*"/>
4
  • Are you in charge of the domain from which you're attempting to fetch resources? Or does someone else control it? Commented Apr 16, 2017 at 6:26
  • @JeremiahMegel I'm in charge of it Commented Apr 16, 2017 at 6:28
  • 1
    The cross domain server on which you are firing the request should have crosa domain requests enabled on its end Commented Apr 16, 2017 at 6:28
  • You probably want to use stackoverflow.com/posts/43434350/edit to edit/update the question to add a code snippet to show what JavaScript code you already tried which is causing that message to be emitted. You should also indicate whether or not you control the server you're sending the request to, and if not, then include the URL for the request you're trying Commented Apr 16, 2017 at 6:33

2 Answers 2

1

You need to set an Access-Control-Allow-Origin HTTP header (not an HTML <meta> tag) on the target resource. Set it to either Access-Control-Allow-Origin: source-domain.example.com to allow only your source domain access to it or Access-Control-Allow-Origin: * to allow any domain access. The first is preferred.

Sign up to request clarification or add additional context in comments.

Comments

0

meta http-equiv is not equivalent to an HTTP header. You must make a request to an HTTP server, and it must respond with real HTTP headers.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.