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. [Python Cookbook] Numpy: Iterating Over Arrays

    1. Using for-loop Iterate along row axis: import numpy as np x=np.array([[1,2,3],[4,5,6]]) for i in ...

  2. codevs——2841 愤怒的LJF(背包)

    样例有误!  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description LJF发现ZPC的积分比他高,他很愤怒. 他挤出T ...

  3. Codeforces 583 DIV2 GCD Table 贪心

    原题链接:http://codeforces.com/problemset/problem/583/C 题意: 大概就是给你个gcd表,让你还原整个序列. 题解: 由$GCD(a,a)=a$,我们知道 ...

  4. Java中的文件上传(原始Servlet实现)

    从原始的Servlet来实现文件的上传,代码如下: 参考:https://my.oschina.net/Barudisshu/blog/150026 采用的是Multipart/form-data的方 ...

  5. numpy基础语法

    np.zeros(5) [ 0.  0.  0.  0.  0.] 所得类型为数组, numpy.zeros_like(a, dtype=None, order='K', subok=True) 生成 ...

  6. ylb:了解存储过程

    ylbtech-SQL Server:SQL Server-了解存储过程 了解存储过程 ylb:了解存储过程 返回顶部 存储过程 2.2.1 主要的编程结构: 变量 数据类型 输入/输出变量 返回值 ...

  7. hadoop datanode节点超时时间设置

    datanode进程死亡或者网络故障造成datanode无法与namenode通信,namenode不会立即把该节点判定为死亡,要经过一段时间,这段时间暂称作超时时长. HDFS默认的超时时长为10分 ...

  8. tts和字符集的关系--要求源和目的端的数据库字符集必须一样,国家字符集必须一样。

    tts和字符集的关系--要求源和目的端的数据库字符集必须一样,国家字符集必须一样. imp sys/as TRANSPORT_TABLESPACE=Y datafiles= C:\oracle\pro ...

  9. Spring boot Security Disable security

    When I use security.basic.enabled=false to disable security on a Spring Boot project that has the fo ...

  10. Wireshark网络分析实战笔记(三)基本信息统计工具的使用方法

    Capture File Properties:获取网络中数据包的整体信息 用法:Statistics菜单条下Capture File Properties选项 Protocol Hierarchy: ...