Failed to load http://wantTOgo.com/get_sts_token/:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://fromHere.com' is therefore not allowed access.

package main

import (
"./myKey"
"fmt"
"os" "github.com/aliyun/aliyun-sts-go-sdk/sts"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"net/http"
) func handleError(err error) {
fmt.Println(err)
os.Exit(-1)
} const (
accessKeyID = myKey.AccessKeyID
accessKeySecret = myKey.AccessKeySecret
roleArn = myKey.RoleArn
sessionName = myKey.SessionName
) type ExceptionResp struct {
Status string
Message string
} func main() {
e := echo.New()
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
// AllowOrigins: []string{"https://labstack.com", "https://labstack.net"},
AllowOrigins: []string{"*"},
// AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
AllowHeaders: []string{"*"},
}))
e.GET("/aliSTS/:uid", func(c echo.Context) error {
uid := c.Param("uid")
fmt.Println("LOG ", uid)
stsClient := sts.NewClient(accessKeyID, accessKeySecret, roleArn, sessionName)
resp, err := stsClient.AssumeRole(3600)
if err != nil {
handleError(err)
r := &ExceptionResp{
Status: "-1",
Message: "what?",
}
return c.JSON(http.StatusOK, r)
}
r := resp.Credentials
return c.JSON(http.StatusOK, r)
})
e.Logger.Fatal(e.Start(":1324"))
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
<script>
const ourSTSurl = 'http://blackhole.com:1324/aliSTS/33333'
const xhr = new XMLHttpRequest()
const verb = 'GET'
xhr.open(verb,ourSTSurl)
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
xhr.send()
console.log(xhr)
</script>

												

最新文章

  1. 对于挑战书上的很久之前都看不懂的DP看懂的突破
  2. PL/SQL Developer连接本地Oracle 11g 64位数据库
  3. CodeForces 710CMagic Odd Square(经典-奇数个奇数&amp;偶数个偶数)
  4. MySQL数据库监控
  5. 如何提交docker镜像到DockerHub
  6. SpringMVC 2.5.6 noMapping
  7. 【BZOJ】1602: [Usaco2008 Oct]牧场行走(lca)
  8. ArcEngine开发:IElement.Geometry 值不在预期范围内 + 元素绘制代码
  9. Java JDK8 安装及环境变量配置
  10. Android 仿Win8的metro的UI界面(上)
  11. HTML5 总结-画布-4
  12. (转)Linux端口nmap和netstat命令
  13. Redis学习笔记之一 : 配置redis
  14. C++11新特性应用--介绍几个新增的便利算法(不更改容器中元素顺序的算法)
  15. 山东省第八届ACM大学生程序设计竞赛
  16. Query the tables and index which will caus rebuild index fail
  17. Problem F: 平面上的点——Point类 (VI)
  18. TypeScript 之 NPM包的类型
  19. Android 混淆代码有关问题总结
  20. JAVA之访问控制符

热门文章

  1. 暂停时间 以及dict 循环
  2. pt-query-digest 实践(转)
  3. HTTP协议header头域
  4. Android Retrofit使用教程
  5. 一入python深似海--range()、list与for
  6. nginx rewrite arg 带问号的地址转发参数处理?Nginx重定向的参数问题
  7. 自编自演的Linux脚本
  8. AngularJS的稍复杂form验证
  9. 本地搭建Hadoop伪分布式环境之四:开启搭建Hadoop2.4.0之旅
  10. UVA12096 - The SetStack Computer(set + map映射)