Skip to content

Commit

Permalink
fix: respect KVS.getPublicUrl() from core when not on apify platform (
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan authored May 29, 2024
1 parent f100252 commit a4d80bb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/apify/src/key_value_store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import type { StorageManagerOptions } from '@crawlee/core';
import { KeyValueStore as CoreKeyValueStore } from '@crawlee/core';

import type { Configuration } from './configuration';

// @ts-ignore newer crawlee versions already declare this method in core
const { getPublicUrl } = CoreKeyValueStore.prototype;

/**
* @inheritDoc
*/
Expand All @@ -10,6 +15,10 @@ export class KeyValueStore extends CoreKeyValueStore {
* access the value in the remote key-value store.
*/
getPublicUrl(key: string): string {
if (!(this.config as Configuration).get('isAtHome') && getPublicUrl) {
return getPublicUrl.call(this, key);
}

return `https://api.apify.com/v2/key-value-stores/${this.id}/records/${key}`;
}

Expand All @@ -21,5 +30,5 @@ export class KeyValueStore extends CoreKeyValueStore {
}
}

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

0 comments on commit a4d80bb

Please sign in to comment.