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.
2024-08-30 03:04:31
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>
最新文章
- 对于挑战书上的很久之前都看不懂的DP看懂的突破
- PL/SQL Developer连接本地Oracle 11g 64位数据库
- CodeForces 710CMagic Odd Square(经典-奇数个奇数&;偶数个偶数)
- MySQL数据库监控
- 如何提交docker镜像到DockerHub
- SpringMVC 2.5.6 noMapping
- 【BZOJ】1602: [Usaco2008 Oct]牧场行走(lca)
- ArcEngine开发:IElement.Geometry 值不在预期范围内 + 元素绘制代码
- Java JDK8 安装及环境变量配置
- Android 仿Win8的metro的UI界面(上)
- HTML5 总结-画布-4
- (转)Linux端口nmap和netstat命令
- Redis学习笔记之一 : 配置redis
- C++11新特性应用--介绍几个新增的便利算法(不更改容器中元素顺序的算法)
- 山东省第八届ACM大学生程序设计竞赛
- Query the tables and index which will caus rebuild index fail
- Problem F: 平面上的点——Point类 (VI)
- TypeScript 之 NPM包的类型
- Android 混淆代码有关问题总结
- JAVA之访问控制符
热门文章
- 暂停时间 以及dict 循环
- pt-query-digest 实践(转)
- HTTP协议header头域
- Android Retrofit使用教程
- 一入python深似海--range()、list与for
- nginx rewrite arg 带问号的地址转发参数处理?Nginx重定向的参数问题
- 自编自演的Linux脚本
- AngularJS的稍复杂form验证
- 本地搭建Hadoop伪分布式环境之四:开启搭建Hadoop2.4.0之旅
- UVA12096 - The SetStack Computer(set + map映射)