Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

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

Shulou Source: shulou.com Published: 2022-06-02 02:21:18 09月20日 Update

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.

Tags: Front end parameters browser browsing problems differences methods violence more knowledge articles services utility between code names that is properties work meetings common Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Shulou Information Huawei Xiaomi