2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-05 16:42:32 +03:00

Fixing baseURL not working in interceptors (#950)

* Fixing baseURL not working in interceptors

* add test for  modify base URL in request interceptor
This commit is contained in:
Haven
2017-08-12 20:15:27 +08:00
committed by Rubén Norte
parent 6508280bbf
commit 2b8562694e
3 changed files with 25 additions and 7 deletions
+7
View File
@@ -4,6 +4,8 @@ var utils = require('./../utils');
var transformData = require('./transformData');
var isCancel = require('../cancel/isCancel');
var defaults = require('../defaults');
var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
var combineURLs = require('./../helpers/combineURLs');
/**
* Throws a `Cancel` if cancellation has been requested.
@@ -23,6 +25,11 @@ function throwIfCancellationRequested(config) {
module.exports = function dispatchRequest(config) {
throwIfCancellationRequested(config);
// Support baseURL config
if (config.baseURL && !isAbsoluteURL(config.url)) {
config.url = combineURLs(config.baseURL, config.url);
}
// Ensure headers exist
config.headers = config.headers || {};