Nuxt.js project request cross-domain

in the website built by nuxt.js, a request is sent in the asyncData method on the home page. The interface address is forwarded with nginx. The background log checks the returned data, but the front end does not receive the returned data. The website cannot be opened
call the console to report an error before the component is loaded

configure in nginx

clipboard.png

clipboard.png
seek the solution

Mar.14,2021

    Don't requests in
  1. asyncData be sent once during server ssr? this time there is no cross-domain problem.
  2. the prompt you see in the browser console should be that the server data request failed, resulting in no client retransmission caused by _ _ INITIAL_STATE__ , and cross-domain error.
  3. the error message you didn't intercept in the second paragraph should be only one allowed . Is there any other place in nginx where Access-Control-Allow-Origin is set? is it set twice? Or the response head is not set correctly.
Menu