Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the cross-domain problem of local localhost front-end transferring local localhost back-end

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to solve the cross-domain problem of local localhost front-end transferring local localhost back-end. The editor thinks it is very practical, so I share it with you for study. I hope you can get something after reading this article.

When debugging front-end and back-end separation, use your own front-end to adjust your own back-end, and the browser reports an error No 'Access-Control-Allow-Origin' header is present on the requested resource.

Common methods of setting response headers have been tried, and finally, local debugging is realized by modifying browser parameters with violence. This method is only used to debug local code, and debugging before calls to different services is not recommended. Call debugging between different services can be solved by setting response parameters.

HttpServletResponse.setHeader ("Access-Control-Allow-Origin", "*"); httpServletResponse.setHeader ("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); httpServletResponse.setHeader ("Access-Control-Allow-Credentials", "true")

Solutions to violence:

Create a new Google browser shortcut named chrome_debug (random name), right-click the property, add the parameter "--user-data-dir=" c:\ ChromeDebug "--test-type-- disable-web-security", "- -" in front of a space, re-sign in the newly created chrome_debug and start debugging.

The above is how to solve the cross-domain problem of transferring the local localhost front end to the local localhost backend. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report