Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

vue CORS

//in your vue.config.js
module.exports = {
  devServer: {
    proxy: {
      "/api": {
        target: "<API BASE URL>",
        changeOrigin: true,
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },
}

//in store actions account.js

let corsAnywhere = "https://corsanywhere.herokuapp.com"

let options = {
  url:
  process.env.NODE_ENV === "production"
  ? `${corsAnywhere}/API BASE URL/END POINT`
  : "/api/END POINT",
  method: "GET",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
  },
  data: {},
}

axios(options).then(respnse => {}).catch(error => {})
Comment

PREVIOUS NEXT
Code Example
Javascript :: Simple code example of adding two numbers in javascript 
Javascript :: generate random string react 
Javascript :: angular ngmodel checkbox 
Javascript :: testing library react hooks 
Javascript :: best and fastest encrypt and decrypt value in javascript 
Javascript :: shadow react native 
Javascript :: data-id html javascript 
Javascript :: array_diff in jquery 
Javascript :: switch case in javascript 
Javascript :: object destructuring javascript 
Javascript :: javascript append child 
Javascript :: how to read xml element in xml2js 
Javascript :: discord.js emoji in embed 
Javascript :: js if array is 2d 
Javascript :: set attribute using each jquery 
Javascript :: javascript on window resize 
Javascript :: axio post file 
Javascript :: nest navigation react navigation 
Javascript :: date now js 
Javascript :: flutter intl currency 
Javascript :: check if a value is an object in javascript 
Javascript :: html set textarea value 
Javascript :: js platformer 
Javascript :: js send file as form input 
Javascript :: create an object array in js 
Javascript :: loop through dom elements javascript 
Javascript :: javascript dynamic arrays 
Javascript :: js click counter 
Javascript :: javascript object to array 
Javascript :: regex expression to match domain name 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =