Skip to content

issue-1704: Allow empty base url in server configuration. #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@angular/cli": "~8.3.25",
"@angular/compiler-cli": "8.1.0",
"@angular/language-service": "8.1.0",
"@babel/compat-data": "~7.8.0",
"@ngxs/devtools-plugin": "^3.3.4",
"@ngxs/logger-plugin": "^3.3.4",
"@types/antlr4-autosuggest": "0.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<mat-form-field>
<input matInput placeholder="Base URL" formControlName="baseUrl" #url>
<mat-hint>
The URL from which Strongbox is accessed (i.e. if you're using reverse proxy
this should be the public url)
(Optional) If set it will be used when generating links across Strongbox.
If empty - will guess automatically using request headers.
</mat-hint>
<mat-error>
<form-field-errors formControlName="baseUrl"></form-field-errors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ManageSettingsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.settingsForm = new FormGroup({
instanceName: new FormControl(this.randomName(), [Validators.required, Validators.minLength(3)]),
baseUrl: new FormControl(this.guessUrl(), [Validators.required]),
baseUrl: new FormControl(null, []),
port: new FormControl(48080, [
Validators.required,
(control: FormControl) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,21 @@ export class DirectoryListingComponent implements OnInit, OnDestroy {
}

downloadFile(pathRecord: PathRecord): void {

this.http
.get(pathRecord.url, {responseType: 'arraybuffer'})
.subscribe((buffer: ArrayBuffer) => {
if (pathRecord.name.match(/md5|sha1$/i)) {
if (pathRecord.name.match(/md5|sha1$/i)) {
this.http
.get(pathRecord.url, {responseType: 'arraybuffer'})
.subscribe((buffer: ArrayBuffer) => {
pathRecord.description = String.fromCharCode.apply(null, new Uint8Array(buffer));
this.cdr.detectChanges();
} else {
const blob: Blob = new Blob([buffer], {type: 'application/octet-stream'});
const fileName = pathRecord.name;
const objectUrl: string = URL.createObjectURL(blob);
const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement;

a.href = objectUrl;
a.download = fileName;
document.body.appendChild(a);
a.click();

document.body.removeChild(a);
URL.revokeObjectURL(objectUrl);
}
});
});
} else {
const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement;
a.href = pathRecord.url;
a.target = '_window';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
}

confirmDelete(pathRecord: PathRecord) {
Expand All @@ -124,7 +117,6 @@ export class DirectoryListingComponent implements OnInit, OnDestroy {
});
}


sortPathRecord(a: PathRecord, b: PathRecord
) {
return a.name.toLocaleLowerCase().localeCompare(b.name.toLocaleLowerCase());
Expand Down
21 changes: 12 additions & 9 deletions tools/proxy.conf.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
const filter = function(pathname, req) {
return req.method === 'GET' && pathname.match('^/(index\.html)?$')
};

const LOCAL_IP = '127.0.0.1';

const proxyEndpoints = [
"/api",
"/storages"
];

const PROXY_CONFIG = [
{
context: filter,
context: function(pathname, req) {
return req.method === 'GET' && (
pathname.match('^/(index\.html)?$') ||
!pathname.match('^' + proxyEndpoints.join("|") + '|/static')
)
},
target: `http://${LOCAL_IP}:4200/static/assets`,
secure: false,
logLevel: "debug"
},
{
context: [
"/api",
"/storages"
],
context: proxyEndpoints,
target: `http://${LOCAL_IP}:48080`,
secure: false,
logLevel: "debug",
Expand Down