zoukankan      html  css  js  c++  java
  • 记录vue springboot 跨域采坑


    vue配置 域名srcmain.js要与configindex.js一样


    var axios = require('axios')
    axios.defaults.baseURL = 'http://localhost:2020/api'
    // 使请求带上凭证信息
    axios.defaults.withCredentials = true


    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
    '/api': {
    target: 'http://localhost:2020',
    changeOrigin: true,
    pathRewrite: {
    '^/api': ''
    }
    }
    },



    spring 配置comevangdconfigMyWebConfigurer.java

    @Override
    public void addCorsMappings(CorsRegistry registry) {
    //所有请求都允许跨域,使用这种配置方法就不能在 interceptor 中再配置 header 了
    registry.addMapping("/**")
    .allowCredentials(true)
    .allowedOrigins("http://localhost:8080")
    .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
    .allowedHeaders("*")
    .maxAge(3600);
    }
  • 相关阅读:
    ByteBuffer使用实例
    Fiddler抓包显示请求时延
    手机wifi连上Fiddler后无网络问题解决
    git
    git
    Autofac使用
    Redis实战
    Redis实战
    Redis实战
    Redis实战
  • 原文地址:https://www.cnblogs.com/gaodi2345/p/13549064.html
Copyright © 2011-2022 走看看