vue开发环境跨域配置(全网唯一正确解释)

2021年3月14日 06:04 by wst

web开发

记录在vue开发中跨域问题的解决方法

域名重定向

配置选项(vue.config.js)的写法:

module.exports = {
    baseUrl: './',
    assetsDir: 'static',
    productionSourceMap: false,
    devServer: {
        proxy: {
            '/api':{
                target:'https://api.xxxxx.com',
                // target:'',
                changeOrigin:true,
                pathRewrite:{
                    '^/api':''
                }
            }
        }
    }
}

baseUrl配置:

// create an axios instance
const service = axios.create({
  baseURL: "/api", // url = base url + request url
  // withCredentials: true, // send cookies when cross-domain requests
  timeout: 5000 // request timeout
})

经过实践,得出结论,部分代码解释如下:

某个业务请求路径 '/boss/mg/user/count' 会经过如下转换:

1.  拼接:上文的路径首先拼接为 /api/boss/mg/user/count

2. 重定向:

      (1)/api 被替换成 https://api.xxxxx.com,即:https://api.xxxxx.com/boss/mg/user/count  (这是错误解释)

经过查阅官方文档,正确解释为

(1)/api 下的配置项 target指的是被定向到的服务器地址,即:

/api/boss/mg/user/count => https://api.xxxxx.com/api/boss/mg/user/count

(2)然后是路径的重定向,'^/api':'' ,即 ^/api 被替换成空字符:

https://api.xxxxx.com/api/boss/mg/user/count => https://api.xxxxx.com/boss/mg/user/count 

事实上服务端暴露出来的接口地址正是https://api.xxxxx.com/boss/mg/user/count

 

参考:https://github.com/chimurai/http-proxy-middleware#proxycontext-config


Comments(127) Add Your Comment

Charlesnag
“I haven’t seen you in these parts,” the barkeep said, sidling settled to where I sat. “Personage’s Bao.” He stated it exuberantly, as if word of his exploits were shared by settlers about multifarious a fire in Aeternum. He waved to a wooden butt apart from us, and I returned his token with a nod. He filled a glass and slid it to me across the stained red wood of the bar in the vanguard continuing. “As a betting fellow, I’d be delighted to wager a fair portion of coin you’re in Ebonscale Reach in search more than the wet one's whistle and sights,” he said, eyes glancing from the sword sheathed on my with it to the salaam slung across my back. https://maps.google.co.zw/url?q=https://renewworld.ru/budet-li-russkiy-yazyk-v-new-world/
Kevingaw
https://images.google.bg/url?q=https://www.simacek.com/present/inc/wie_man_ein_casino_online_schl_gt__clevere_tipps_f_r_anf_nger_und_erfahrene_spieler.html https://www.google.hu/url?q=http://1xbitpromocode.org/ http://images.google.com.pe/url?q=https://www.stadt-berga.de/wp-includes/pgs/?welches_casino_zahlt_am_schnellsten_aus____top_5_online_casinos_mit_guter_rendite_2022.html https://druckerei-festge.de/wp-content/pages/welches_casino_zahlt_am_schnellsten_aus___ein_casino_mit_einer_guten_auszahlungsrate.html http://band-merch.de/wp-content/pages/wie_man_ein_online_casino_oder_einen_verdopplungsplan__berlistet.html
Uqejgq
lipitor order <a href="https://lipiws.top/">buy lipitor without a prescription</a> buy lipitor generic
Arclye
baycip usa - <a href="https://metroagyl.top/oxytetracycline/">myambutol 600mg tablet</a> amoxiclav pills
Pnbofa
buy cheap baycip - <a href="https://cipropro.top/keflexcapsule/">buy keflex 250mg</a> order amoxiclav
Kcmeke
brand flagyl - <a href="https://metroagyl.top/">flagyl uk</a> buy azithromycin 250mg generic
Nxtius
ciplox 500mg uk - <a href="https:/septrim.top/">buy ciplox 500 mg pills</a> erythromycin where to buy
Vjroch
valtrex 500mg price - <a href="https://gnantiviralp.com/diltiazem/">generic diltiazem 180mg</a> acyclovir pills
Giduby
ivermectin 2mg - <a href="https://keflexin.top/ceftin/">cheap cefuroxime 500mg</a> order generic tetracycline
Hytbem
purchase metronidazole - <a href="https://metroagyl.top/oxytetracycline/">oxytetracycline generic</a> order zithromax 250mg online
Xfsimk
order generic ampicillin <a href="https://ampiacil.top/amoxil500/">purchase amoxicillin generic</a> purchase amoxil for sale
Qxifvr
buy furosemide 40mg online - <a href="https://antipathogenc.com/atacand/">cost candesartan</a> buy capoten 25mg pills
Jxncjv
buy zidovudine pill - <a href="https://canadiangnp.com/">order metformin 1000mg</a> order zyloprim for sale
Edamtg
buy metformin 500mg generic - <a href="https://gnantiacidity.com/lincocin/">order lincocin 500 mg</a> buy lincomycin 500 mg online
Esmdfc
clozapine 100mg tablet - <a href="https://genonlinep.com/frumil/">buy frumil tablets</a> famotidine for sale
Mnnvpw
buy quetiapine generic - <a href="https://gnkantdepres.com/effexor/">buy generic venlafaxine 150mg</a> buy generic eskalith over the counter
Hvqnqs
buy hydroxyzine 25mg generic - <a href="https://antdepls.com/pamelor/">order generic nortriptyline 25 mg</a> order endep 10mg sale
Ydhepj
cost anafranil 50mg - <a href="https://antdeponline.com/asendin/">order amoxapine 50 mg</a> sinequan ca
Tupzpl
amoxil oral - <a href="https://atbioxotc.com/cefadroxil/">cefadroxil 250mg generic</a> order ciprofloxacin 1000mg pills
Btqkrx
purchase augmentin pills - <a href="https://atbioinfo.com/">purchase augmentin for sale</a> ciprofloxacin 1000mg generic
Syiazh
purchase cleocin pill - <a href="https://cadbiot.com/">cleocin cheap</a> buy chloromycetin generic
Zusxiv
buy zithromax 500mg pill - <a href="https://gncatbp.com/">buy azithromycin generic</a> ciplox 500 mg us
Fbxizq
albuterol 2mg pill - <a href="https://antxallergic.com/cvallegra/">buy allegra pills</a> order theo-24 Cr sale
Elwezr
stromectol 3 mg price - <a href="https://antibpl.com/tylquin/">buy levofloxacin 250mg online cheap</a> buy cefaclor capsules
Xjybpv
buy desloratadine pill - <a href="https://rxtallerg.com/ventolinpill/">purchase albuterol pills</a> albuterol 2mg cost
Eopxec
buy methylprednisolone pills - <a href="https://ntallegpl.com/getcetirizine/">order zyrtec 5mg pill</a> astelin 10ml over the counter
Tguvdl
glyburide 5mg over the counter - <a href="https://prodeprpl.com/dapagliflozin5/">dapagliflozin 10 mg without prescription</a> dapagliflozin price
Fmyvoz
how to get repaglinide without a prescription - <a href="https://depressinfo.com/">prandin tablet</a> empagliflozin 10mg cost
Iwkwfc
glycomet where to buy - <a href="https://arxdepress.com/">metformin 1000mg price</a> precose 25mg ca
Doxbuk
lamisil ca - <a href="https://treatfungusx.com/">lamisil ca</a> griseofulvin drug
Crnqda
semaglutide drug - <a href="https://infodeppl.com/">rybelsus 14mg canada</a> order desmopressin
Ymtaww
ketoconazole 200mg tablet - <a href="https://antifungusrp.com/butenafinecream/">buy mentax paypal</a> cheap sporanox
Rtamog
digoxin 250mg brand - <a href="https://blpressureok.com/">digoxin ca</a> furosemide medication
Nljhqo
purchase famvir generic - <a href="https://amvinherpes.com/acyclovircream/">buy zovirax 800mg generic</a> valaciclovir brand
Eqyrqi
hydrochlorothiazide 25mg cost - <a href="https://norvapril.com/bisoprolol/">order bisoprolol 10mg online</a> order bisoprolol 10mg generic
Ioswsj
lopressor 50mg uk - <a href="https://bloodpresspl.com/hyzaar/">order losartan pill</a> buy adalat 10mg without prescription
Akjiii
nitroglycerin online order - <a href="https://nitroproxl.com/catapres/">buy generic catapres</a> buy valsartan 160mg for sale
Qqlrhs
crestor online niece - <a href="https://antcholesterol.com/caduet5mg/">caduet buy mess</a> caduet online seek
Lszqjc
simvastatin wealth - <a href="https://canescholest.com/gemfibrozil/">lopid content</a> lipitor darken
Sdzqqg
viagra professional online rank - <a href="https://edsildps.com/levitraoraljelly/">levitra oral jelly online russian</a> levitra oral jelly float
Xsdvjy
cenforce pleasure - <a href="https://xcenforcem.com/levitraprofessional/">levitra professional pills far</a> brand viagra pills waste
Tbsvao
priligy length - <a href="https://promedprili.com/sildigra/">sildigra brilliant</a> cialis with dapoxetine pillow
Txuxqi
brand cialis instruction - <a href="https://probrandtad.com/zhewitra/">zhewitra guess</a> penisole exist
Ugqqgt
cialis soft tabs pace - <a href="https://supervalip.com/cialisoraljelly/">cialis oral jelly explode</a> viagra oral jelly nostril
Xqmwyy
brand cialis eventual - <a href="https://probrandtad.com/penisole/">penisole sort</a> penisole gleam
Stranz
cialis soft tabs pills north - <a href="https://supervalip.com/">cialis soft tabs audience</a> viagra oral jelly bottom
Frkwmz
cenforce fancy - <a href="https://xcenforcem.com/kamagrasildenafil/">kamagra online resolve</a> brand viagra online professional
Jqeabg
acne treatment beer - <a href="https://placnemedx.com/">acne medication oak</a> acne treatment footstep
Qoicup
asthma treatment evidence - <a href="https://bsasthmaps.com/">asthma medication same</a> inhalers for asthma thin
Jceqyx
uti treatment relate - <a href="https://amenahealthp.com/">uti medication smile</a> uti medication incredible
Nxetjt
prostatitis treatment firm - <a href="https://xprosttreat.com/">pills for treat prostatitis beckon</a> prostatitis pills sensation
Cfgswc
valacyclovir resume - <a href="https://gnantiviralp.com/">valacyclovir pills instance</a> valtrex pills imagination
Ihsnvv
claritin pills italian - <a href="https://clatadine.top/">claritin pills rise</a> claritin pills bank
Hoxlgh
loratadine vision - <a href="https://clatadine.top/">loratadine medication stumble</a> loratadine bill
Pqspkj
priligy hey - <a href="https://prilixgn.top/">dapoxetine extent</a> dapoxetine peter
Gqyans
promethazine shoulder - <a href="https://prohnrg.com/">promethazine pitch</a> promethazine forever
Hgiims
ascorbic acid grunt - <a href="https://ascxacid.com/">ascorbic acid surprise</a> ascorbic acid stroll
Garzgx
florinef chuckle - <a href="https://gastroplusp.com/prlansoprazole/">lansoprazole longer</a> lansoprazole pills chill
Fwcgog
buy bisacodyl sale - <a href="https://gastroinfop.com/oxybutynin/">ditropan where to buy</a> liv52 uk
Ytsbhw
buy aciphex 10mg for sale - <a href="https://gastrointesl.com/reglanmetoclop/">buy reglan sale</a> buy motilium tablets
Hkumom
cotrimoxazole medication - <a href="https://cotrioxazo.com/">buy cotrimoxazole no prescription</a> tobra 5mg brand
Zpyavn
buy eukroma online cheap - <a href="https://dupsteron.com/">buy generic dydrogesterone online</a> duphaston 10mg over the counter
Kbbetz
order generic forxiga 10 mg - <a href="https://forpaglif.com/">order forxiga generic</a> buy acarbose paypal
Yxqrii
buy griseofulvin 250 mg without prescription - <a href="https://fulviseoful.com/">griseofulvin price</a> purchase lopid for sale
Ntfkym
where can i buy vasotec - <a href="https://doxapisin.com/">purchase doxazosin online cheap</a> zovirax medication
Ugueei
buy dimenhydrinate 50mg sale - <a href="https://prasilx.com/">cheap prasugrel 10mg</a> actonel over the counter
Pmvkuj
order feldene - <a href="https://feldexicam.com/">order feldene 20mg online</a> brand exelon 3mg
Nzfbtm
order etodolac online cheap - <a href="https://etodograph.com/">order etodolac 600mg online</a> buy generic pletal
Gptocf
hydrea sale - <a href="https://hydroydrinfo.com/methocarbamol/">robaxin 500mg canada</a> methocarbamol generic
Kaelkq
nootropil order - <a href="https://nootquin.com/efavirenz/">sustiva 10mg tablet</a> oral sinemet 20mg
Jsvjnf
brand norpace - <a href="https://anorpica.com/lamotrigine/">lamotrigine 200mg tablet</a> thorazine cost
Ubpopl
brand depakote - <a href="https://adepamox.com/topiramate/">order generic topiramate 100mg</a> topamax 100mg uk
Rmyrct
cyclophosphamide online buy - <a href="https://cycloxalp.com/stavudine/">how to get zerit without a prescription</a> trimetazidine online buy
Mkaxhf
buy aldactone no prescription - <a href="https://aldantinep.com/naltrexone/">revia 50 mg uk</a> revia 50mg drug
Idoylt
order zofran 4mg pill - <a href="https://azofarininfo.com/">ondansetron 8mg uk</a> cheap ropinirole
Hyujnx
buy cyclobenzaprine without prescription - <a href="https://abflequine.com/olanzapine/">buy olanzapine without a prescription</a> enalapril brand
Fsnqav
buy ascorbic acid tablets - <a href="https://mdacidinfo.com/isosorbidedinitrate/">buy generic isosorbide dinitrate</a> prochlorperazine order online
Qxlsav
order durex gel cheap - <a href="https://xalaplinfo.com/">durex gel online buy</a> brand latanoprost
Ydanfd
arava order online - <a href="https://infohealthybones.com/cartidin/">buy cartidin online cheap</a> order cartidin
Aosbzw
rogaine price - <a href="https://hairlossmedinfo.com/">purchase minoxidil generic</a> oral proscar 5mg
Wbttpw
atenolol over the counter - <a href="https://heartmedinfox.com/carvedilol/">coreg 6.25mg usa</a> coreg 6.25mg cost
Dlsggu
buy generic calan 120mg - <a href="https://infoheartdisea.com/cardizem/">order diltiazem generic</a> buy tenoretic without prescription
Fnfbag
order atorlip - <a href="https://infoxheartmed.com/lisinopril/">lisinopril online order</a> purchase nebivolol pills
Xwjfjf
purchase lasuna online cheap - <a href="https://infoherbalmz.com/himcolin/">buy himcolin tablets</a> cheap himcolin generic
Yqryjl
gasex sale - <a href="https://herbalinfomez.com/ashwagandha/">cheap ashwagandha</a> buy diabecon online cheap
Urjjge
where can i buy speman - <a href="https://spmensht.com/himplasia/">buy generic himplasia</a> order fincar pills
Plvqbz
buy norfloxacin - <a href="https://gmenshth.com/confido/">confido price</a> confido over the counter
Zdepbv
buy cheap finasteride - <a href="https://finmenura.com/">order finasteride pills</a> uroxatral for sale online
Ccqvgo
buy terazosin without prescription - <a href="https://hymenmax.com/dutasteride/">dutasteride canada</a> priligy online order
Dmcnwq
lactulose us - <a href="https://duphalinfo.com/betahistine/">buy betahistine 16mg generic</a> buy betahistine 16mg generic
Pecfgw
order trileptal 300mg online - <a href="https://trileoxine.com/pirfenidone/">pirfenidone over the counter</a> order levothroid generic
Njegdx
buy cyclosporine sale - <a href="https://asimusxate.com/methotrexate/">methotrexate 2.5mg oral</a> purchase colcrys generic
Kshqpo
buy calcort online cheap - <a href="https://lazacort.com/brimonidine/">order generic brimonidine</a> buy alphagan medication
Bsmvkd
cheap gabapentin 800mg - <a href="https://aneutrin.com/">order gabapentin 100mg pills</a> azulfidine buy online
Udptfx
buy benemid 500mg online - <a href="https://bendoltol.com/">buy probenecid pills</a> carbamazepine cost
Gltaqe
buy celebrex 100mg for sale - <a href="https://celespas.com/flavoxate/">urispas cheap</a> indocin 75mg price
Rccfjt
buy mebeverine 135 mg pills - <a href="https://coloxia.com/etoricoxib/">buy etoricoxib no prescription</a> order pletal 100mg without prescription
Dtmosz
cambia tablet - <a href="https://dicloltarin.com/aspirin/">buy aspirin medication</a> purchase aspirin
Bebbwl
pyridostigmine 60mg tablet - <a href="https://mestonsx.com/azathioprine/">order generic azathioprine 50mg</a> buy imuran 25mg generic
Dcbirz
buy rumalaya generic - <a href="https://rumaxtol.com/shallaki/">cheap shallaki for sale</a> order elavil 50mg pill
Bxvgtq
ozobax without prescription - <a href="https://baclion.com/">baclofen brand</a> feldene 20 mg sale
Nasfba
purchase voveran pills - <a href="https://vovetosa.com/tisosorbide/">isosorbide 40mg generic</a> how to get nimodipine without a prescription
Elfggu
order cyproheptadine 4 mg for sale - <a href="https://periheptadn.com/aszanaflex/">tizanidine pills</a> order tizanidine 2mg online
Mgwiuv
order meloxicam without prescription - <a href="https://meloxiptan.com/rtrizatriptan/">purchase toradol generic</a> buy generic toradol
Kkekoi
buy omnicef without prescription - <a href="https://omnixcin.com/aminocycline/"></a> how to get clindamycin without a prescription
Uffhjm
buy trihexyphenidyl pill - <a href="https://voltapll.com/diclofenacgel/">diclofenac gel purchase online</a> voltaren gel where to order
Xfxegx
buy prednisone 5mg for sale - <a href="https://apreplson.com/">deltasone 5mg pills</a> how to get permethrin without a prescription
Sqwnoa
purchase accutane online cheap - <a href="https://aisotane.com/">accutane 20mg over the counter</a> deltasone 20mg without prescription
Oqyphm
acticin cream - <a href="https://actizacs.com/">permethrin online buy</a> tretinoin gel cheap
Ahtsyk
betnovate 20gm cheap - <a href="https://betnoson.com/">betnovate online order</a> monobenzone online buy
Akapfc
flagyl 200mg pills - <a href="https://ametronles.com/">cheap metronidazole</a> buy cenforce medication
Xxdluh
augmentin 1000mg uk - <a href="https://baugipro.com/">augmentin 375mg tablet</a> buy cheap synthroid online
Wzogso
cozaar 25mg for sale - <a href="https://acephacrsa.com/">order keflex sale</a> buy keflex 125mg online cheap
Dtozzd
clindamycin us - <a href="https://clinycinpl.com/">clindamycin generic</a> cheap indomethacin 50mg
Cemqip
order provigil 200mg generic - <a href="https://sleepagil.com/">modafinil cheap</a> meloset 3 mg pills
Wisgws
crotamiton for sale - <a href="https://aeuracream.com/caczone/">purchase aczone pills</a> buy aczone gel for sale
Wlenlj
order bupropion 150 mg pills - <a href="https://bupropsl.com/shuddhaguggulu/">shuddha guggulu without prescription</a> order shuddha guggulu pill
Qgvcco
xeloda pills - <a href="https://xelocap.com/danocrine/">danazol price</a> danocrine 100 mg over the counter
Fsrutx
purchase prometrium online - <a href="https://apromid.com/clomipheneferto/">cheap fertomid for sale</a> buy generic fertomid online
Trhpav
buy fosamax 35mg online cheap - <a href="https://pilaxmax.com/tamoxifen/">cheap tamoxifen 20mg</a> buy medroxyprogesterone online
Pjkmbe
aygestin uk - <a href="https://norethgep.com/lumigan/">lumigan tablet</a> buy yasmin sale
Evulkn
oral yasmin - <a href="https://festrolp.com/anastrozole/">order arimidex 1mg without prescription</a> buy arimidex 1mg
Zbhgah
dostinex 0.5mg sale - <a href="https://adostilin.com/cabgolin/">cabgolin tablet</a> alesse over the counter
Ydwoat
プレドニン処方 - <a href="https://jpaonlinep.com/jazithromycin/">アジスロマイシン錠 500mg 強さ</a> アジスロマイシン 市販 おすすめ
Gkcvle
ばいあぐら - <a href="https://jpedpharm.com/">バイアグラ通販おすすめ</a> シアリス通販 安全
Lnyafo
プレドニン 飲み方 - <a href="https://jpanfarap.com/jpadoxycycline/">ドキシサイクリン通販おすすめ</a> イソトレチノイン 副作用
Zabqmj
eriacta nod - <a href="https://eriagra.com/">eriacta dish</a> forzest lodge