Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
fix: proxy webpack setting
Browse files Browse the repository at this point in the history
- it allows download tarballls in the same origin
- update webpack dev server
- add scenario for blob
  • Loading branch information
juanpicado committed Jul 28, 2019
1 parent 9d006ad commit 5c484bb
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 196 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"webpack": "4.20.2",
"webpack-bundle-analyzer": "3.3.2",
"webpack-bundle-size-analyzer": "3.0.0",
"webpack-cli": "3.2.3",
"webpack-dev-server": "3.2.1",
"webpack-cli": "3.3.6",
"webpack-dev-server": "3.7.2",
"webpack-merge": "4.2.1",
"whatwg-fetch": "3.0.0",
"xss": "1.0.6"
Expand Down
7 changes: 6 additions & 1 deletion src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ function handleResponseType(response: Response): Promise<[boolean, Blob | string
if (contentType.includes('text/')) {
return Promise.all([response.ok, response.text()]);
}

// unfortunatelly on download files there is no header available
if (response.url.match(/tgz/).length > 0) {
return Promise.all([response.ok, response.blob()]);
}
}

return Promise.resolve();
}

class API {
public request<T>(url: string, method = 'GET', options: RequestInit = { headers: {} }, isFile: boolean = false): Promise<T> {
public request<T>(url: string, method = 'GET', options: RequestInit = { headers: {} }): Promise<T> {
if (!window.VERDACCIO_API_URL) {
throw new Error('VERDACCIO_API_URL is not defined!');
}
Expand Down
2 changes: 1 addition & 1 deletion tools/dev.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ new WebpackDevServer(compiler, {
},
proxy: [
{
context: ['/-/verdaccio/logo', '/-/verdaccio/packages', '/-/static/logo.png'],
context: ['/-/verdaccio/**', '**/*.tgz'],
target: 'http://localhost:8080',
},
],
Expand Down
2 changes: 1 addition & 1 deletion tools/webpack.dev.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
scope: '',
logo: 'https://verdaccio.org/img/logo/symbol/svg/verdaccio-tiny.svg',
filename: 'index.html',
verdaccioURL: '//localhost:8080',
verdaccioURL: '//localhost:4872',
template: `${env.SRC_ROOT}/template/index.html`,
debug: true,
inject: true,
Expand Down
Loading

0 comments on commit 5c484bb

Please sign in to comment.