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>

												

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.的更多相关文章

  1. XMLHttpRequest cannot load ''. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' ' is therefore not allowed access.

    ajax跨域 禁止访问! 利用Access-Control-Allow-Origin响应头解决跨域请求

  2. elasticsearch按照配置时遇到的一些坑 [Failed to load settings from [elasticsearch.yml]]

    这里整理几个空格引起的问题. 版本是elasticsearch-2.3.0 或者elasticsearch-rtf-master Exception in thread "main" ...

  3. Metaio在Unity3D中报错 Start: failed to load tracking configuration: TrackingConfigGenerated.xml 解决方法

    报错:Start: failed to load tracking configuration: TrackingConfigGenerated.xml Start: failed to load t ...

  4. eclipse报错:Failed to load the JNI shared library

    Eclipse运行时提示“Failed to load the JNI shared library /Java/jre6/bin/client/jvm.dll”的一个解决方案 因为 Eclipse ...

  5. struts的标签库出现Failed to load or instantiate TagExtraInfo class

    使用struts的标签库出现Failed to load or instantiate TagExtraInfo class 最近在使用struts标签库的时候,在eclipse开发环境中是正常的,放 ...

  6. Eclipse - Failed to load the JNI shared Library (JDK)

    When I try opening Eclipse, a pop-up dialog states: Failed to load the JNI shared library "C:/J ...

  7. Failed to load JavaHL Library.

    以前使用的电脑是32位的,安装的svn可以正常使用,但是现在的电脑室64位的,安装好svn后,把项目提交到svn的过程中,总是弹出来一个错误的对话框: Failed to load JavaHL Li ...

  8. win2008server R2 x64 部署.net core到IIS上出现【Failed to load the dll from [C:\Program Files\dotnet\host\fxr\1.0.1\hostfxr.dll], HRESULT: 0x80070057】错误

    win2008server R2 x64 部署.net core到IIS上出现[Failed to load the dll from [C:\Program Files\dotnet\host\fx ...

  9. eclipse failed to load the jni jvm.dll

    问题:打开Eclipse弹出,eclipse failed to load the jni jvm.dll,一般都是本机的JDK与Eclipse位数不等{32-64,64-32} 解决:看本机Java ...

随机推荐

  1. POJ 2411 Mondriaan's Dream [经典状态压缩dp]

    题意:略. 思路:这一题开始做的时候完全没有思路,便去看了别人的题解. 首先,对于这个题目解法想有一个初步的了解,请看这里:http://www.2cto.com/kf/201208/146894.h ...

  2. Displaying Tabbed and Stacked Canvas Using Show_View In Oracle Forms

    Displays the indicated canvas at the coordinates specified by the canvas's X Position and Y Position ...

  3. Linux sed 批量替换字符串和更多用法

    比如,要将目录/modules下面所有文件中的zhangsan都修改成lisi,这样做: # sed -i “s/zhangsan/lisi/g” `grep zhangsan -rl /module ...

  4. NOIP 2014 D2T3 解方程 Hash大法好

    题目大意:给定高次方程an*x^n+...+a1*x^1+a0*x^0=0 求[1,m]区间内有多少个整数根 ai<=10^10000.m<=100W 懒得高精,考场上写的long dou ...

  5. winsock 收发广播包 【转】

    winsock 收发广播包 ☛广播包的概念 广播包通常为了如下两个原因使用:1 一个应用程序希望在本地网络中找到一个资源,而应用程序对于该资源的地址又没有任何先验的知识. 2 一些重要的功能,例如路由 ...

  6. 【Salvation】——项目进展&已取得的成果

    写在前面:这个项目为原创团体项目,其中美术设计与部分关卡功能为其他成员完成,我负责的部分以角色动画和登录注册为主. 一.游戏美术设计 游戏背景,道具,动物,人物帧动画制作全部完成. 1.人物 2.游戏 ...

  7. Java架构师与开发者提高效率的10个工具

    Java受到全球百万计开发者的追捧,已经演变为一门出色的编程语言.最终,这门语言随着技术的变化,不断的被改善以迎合变化的市场需求. 无论你是否拥有一家科技公司,软件已经成为几乎每一个企业不可或缺的一部 ...

  8. SSO 单点登录简单流程(cas)

    配置服务端(链接数据库) 第一步: 下载cas-server端,解压开, 将中的解压开,将该包中的内容放入cas文件夹(新建文件夹)中 然后将这个文件夹放入到服务端的服务器(tomcat)中 将解压开 ...

  9. C++必知必会(1)

    条款1数据抽象 抽象数据类型的用途在于将变成语言扩展到一个特定的问题领域.一般对抽象数据类型的定义须要准训下面步骤: 1.     为类型取一个描写叙述性的名字 2.     列出类型所能运行的操作 ...

  10. vue 父子通信过程

    1.概述 每个 Vue 实例都实现了事件接口,即: 使用 $on(eventName) 监听事件 使用 $emit(eventName, optionalPayload) 触发事件 2.示例一(未传递 ...