@nuxt/http
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -5,2 +5,10 @@ # Changelog | ||
### [0.5.2](https://github.com/nuxt/http/compare/v0.5.1...v0.5.2) (2020-06-05) | ||
### Features | ||
* allow adding custom headers with nuxt config ([#101](https://github.com/nuxt/http/issues/101)) ([2839260](https://github.com/nuxt/http/commit/2839260ea97b18f259f79bb3ea0e97b0aa7228c3)) | ||
* support baseUrl and remove port :443 and :80 when http or https ([#103](https://github.com/nuxt/http/issues/103)) ([fc3e78e](https://github.com/nuxt/http/commit/fc3e78e1307455df506dbc8f6ba5269f28f6e364)) | ||
### [0.5.1](https://github.com/nuxt/http/compare/v0.5.0...v0.5.1) (2020-04-29) | ||
@@ -7,0 +15,0 @@ |
@@ -37,6 +37,13 @@ const path = require('path') | ||
// Support baseUrl | ||
if (moduleOptions.baseUrl && !moduleOptions.baseURL) { | ||
moduleOptions.baseURL = moduleOptions.baseUrl | ||
delete moduleOptions.baseUrl | ||
} | ||
// Apply defaults | ||
const options = { | ||
baseURL: `http://${defaultHost}:${defaultPort}${prefix}`, | ||
browserBaseURL: null, | ||
browserBaseURL: undefined, | ||
proxyHeaders: true, | ||
@@ -49,2 +56,3 @@ proxyHeadersIgnore: ['accept', 'host', 'cf-ray', 'cf-connecting-ip', 'content-length'], | ||
https: false, | ||
headers: {}, | ||
...moduleOptions | ||
@@ -66,3 +74,3 @@ } | ||
// Default browserBaseURL | ||
if (!options.browserBaseURL) { | ||
if (typeof options.browserBaseURL === 'undefined') { | ||
options.browserBaseURL = options.proxy ? prefix : options.baseURL | ||
@@ -82,2 +90,12 @@ } | ||
// Remove port 443 when https | ||
if (options.baseURL.includes('https://')) { | ||
options.baseURL = options.baseURL.replace(':443', '') | ||
} | ||
// Remove port 80 when http | ||
if (options.baseURL.includes('http://')) { | ||
options.baseURL = options.baseURL.replace(':80', '') | ||
} | ||
// Convert http:// to https:// if https option is on | ||
@@ -84,0 +102,0 @@ if (options.https === true) { |
@@ -14,3 +14,2 @@ import KY from 'ky-universal' | ||
setBaseURL (baseURL) { | ||
@@ -30,3 +29,3 @@ this._defaults.prefixUrl = baseURL | ||
const value = !token ? null : (type ? type + ' ' : '') + token | ||
this.setHeader('authorization', value) | ||
this.setHeader('Authorization', value) | ||
} | ||
@@ -90,3 +89,3 @@ | ||
url = url.substr(1) | ||
} | ||
} | ||
@@ -117,2 +116,4 @@ try { | ||
const headers = <%= JSON.stringify(options.headers, null, 2) %> | ||
// Defaults | ||
@@ -123,3 +124,3 @@ const defaults = { | ||
prefixUrl, | ||
headers: {} | ||
headers | ||
} | ||
@@ -129,5 +130,10 @@ | ||
// Proxy SSR request headers headers | ||
defaults.headers = (ctx.req && ctx.req.headers) ? { ...ctx.req.headers } : {} | ||
<% for (let h of options.proxyHeadersIgnore) { %>delete defaults.headers['<%= h %>'] | ||
<% } %><% } %> | ||
if (process.server && ctx.req && ctx.req.headers) { | ||
const reqHeaders = { ...ctx.req.headers } | ||
for (let h of <%= serialize(options.proxyHeadersIgnore) %>) { | ||
delete reqHeaders[h] | ||
} | ||
defaults.headers = { ...reqHeaders, ...defaults.headers } | ||
} | ||
<% } %> | ||
@@ -134,0 +140,0 @@ if (process.server) { |
{ | ||
"name": "@nuxt/http", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Universal HTTP Module for Nuxt.js", | ||
@@ -21,6 +21,6 @@ "repository": "nuxt/http", | ||
"dependencies": { | ||
"@nuxtjs/proxy": "^1.3.3", | ||
"consola": "^2.11.3", | ||
"ky": "^0.19.1", | ||
"ky-universal": "^0.6.0", | ||
"@nuxtjs/proxy": "^2.0.0", | ||
"consola": "^2.12.2", | ||
"ky": "^0.20.0", | ||
"ky-universal": "^0.7.0", | ||
"semver": "^7.3.2" | ||
@@ -27,0 +27,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22892
383
+ Added@nuxtjs/proxy@2.1.0(transitive)
+ Added@types/http-proxy@1.17.15(transitive)
+ Added@types/node@22.10.6(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addedhttp-proxy-middleware@1.3.1(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-plain-obj@3.0.0(transitive)
+ Addedky@0.20.0(transitive)
+ Addedky-universal@0.7.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removed@nuxtjs/proxy@1.3.3(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-proxy-middleware@0.19.2(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedky@0.19.1(transitive)
- Removedky-universal@0.6.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedtr46@0.0.3(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updated@nuxtjs/proxy@^2.0.0
Updatedconsola@^2.12.2
Updatedky@^0.20.0
Updatedky-universal@^0.7.0