Skip to content

Commit 90a82a0

Browse files
committed
fix: respect KVS.getPublicUrl() from core when not on apify platform
1 parent f100252 commit 90a82a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/apify/src/key_value_store.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { StorageManagerOptions } from '@crawlee/core';
22
import { KeyValueStore as CoreKeyValueStore } from '@crawlee/core';
33

4+
import type { Configuration } from './configuration';
5+
6+
// @ts-ignore newer crawlee versions already declare this method in core
7+
const { getPublicUrl } = CoreKeyValueStore.prototype;
8+
49
/**
510
* @inheritDoc
611
*/
@@ -10,6 +15,10 @@ export class KeyValueStore extends CoreKeyValueStore {
1015
* access the value in the remote key-value store.
1116
*/
1217
getPublicUrl(key: string): string {
18+
if (!(this.config as Configuration).get('isAtHome') && getPublicUrl) {
19+
return getPublicUrl.call(this, key);
20+
}
21+
1322
return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
1423
}
1524

@@ -21,5 +30,5 @@ export class KeyValueStore extends CoreKeyValueStore {
2130
}
2231
}
2332

24-
// @ts-expect-error extension of the core class to make this only a type-issue
33+
// @ts-ignore newer crawlee versions already declare this method in core
2534
CoreKeyValueStore.prototype.getPublicUrl = KeyValueStore.prototype.getPublicUrl;

0 commit comments

Comments
 (0)