谈谈前后端分离中的跨域问题

在前后端分离开发过程中常常出现下面这样的错误提示: Access to XMLHttpRequest at 'http://127.0.0.1:8000/apis/users/login/' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. HelloWorld.vue?18db:50 err Error: Network Error at createError (createError.js?16d0:16) at XMLHttpRequest.handleError (xhr.js?ec6c:91) 看到

「编程实例」各语言Hmac-SHA256的base64编码的实现方式

实例来源网络,语言版本可能略有差异,请验证后使用。 Javascript HMAC SHA256 <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha256.js"></script> <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script> <script> var hash = CryptoJS.HmacSHA256("Message", "secret"); var hashInBase64 = CryptoJS.enc.Base64.stringify(hash); document.write(hashInBase64); </script> PHP HMAC SHA256 $s = hash_hmac('sha256', 'Message', 'secret', true); echo base64_encode($s); Java HMAC SHA256 Dependent on Apache Commons Codec to encode in base64. import javax.crypto.Mac; import

「Go模块」- time

time 当前时间 time.Now() 把时间格式化成字符串(time->string) : time.Now().Format(“2006-01-02 15:04:05”) 把日期字符串转化为时间(string -> time) : time.Parse(“01-02-2006”, “06-17-2013”) 把纳秒转化为时间字符串