Skip to content

Commit 2cbe80c

Browse files
committed
Fix breaking change on DO fetch call url
1 parent 0eba1aa commit 2cbe80c

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/components/ObjectBase/constants.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ export const OBMT = {
1212
SIGNEDIP: "signedIp",
1313
CLIENTID: "clientId",
1414
IP: "ip"
15-
}
15+
}
16+
17+
export const OB_ENDPOINT = `https://durable-object`;

src/components/State/State.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MatchResult } from "path-to-regexp";
22
import { apiker } from "../Apiker";
33
import { getClientId, getRawIp, getSignedIp } from "../Auth";
4-
import { OBMT } from "../ObjectBase";
4+
import { OB_ENDPOINT, OBMT } from "../ObjectBase";
55
import { StateFn, StateMethods } from "./interfaces";
66

77
export const getStateMethods = (defaultObjectName: string, matches?: MatchResult<any>) : StateFn =>
@@ -60,7 +60,7 @@ export const parseObjectStateMapping = (objectStateMapping: string, matches?: Ma
6060

6161
export const deleteObjectState = (obj: any, callback: any) =>
6262
async (propertyName: string) => {
63-
const result = await obj.fetch("/delete", {
63+
const result = await obj.fetch(OB_ENDPOINT + "/delete", {
6464
method: "POST",
6565
body: JSON.stringify({
6666
propertyName
@@ -86,7 +86,7 @@ export const deleteObjectState = (obj: any, callback: any) =>
8686

8787
export const deleteAllObjectState = (obj: any, callback: any) =>
8888
async () => {
89-
const result = await obj.fetch("/deleteall", {
89+
const result = await obj.fetch(OB_ENDPOINT + "/deleteall", {
9090
method: "POST"
9191
});
9292

@@ -106,7 +106,7 @@ export const deleteAllObjectState = (obj: any, callback: any) =>
106106

107107
export const getObjectState = (obj: any, callback: any) =>
108108
async (propertyName: string) => {
109-
const result = await obj.fetch("/get", {
109+
const result = await obj.fetch(OB_ENDPOINT + "/get", {
110110
method: "POST",
111111
body: JSON.stringify({
112112
propertyName
@@ -132,7 +132,7 @@ export const getObjectState = (obj: any, callback: any) =>
132132

133133
export const listObjectState = (obj: any, callback: any) =>
134134
async (payload: any) => {
135-
const result = await obj.fetch("/list", {
135+
const result = await obj.fetch(OB_ENDPOINT + "/list", {
136136
method: "POST",
137137
body: payload ? JSON.stringify(payload) : "",
138138
headers: {
@@ -156,7 +156,7 @@ export const listObjectState = (obj: any, callback: any) =>
156156

157157
export const putObjectState = (obj: any, callback: any) =>
158158
async (payload: any) => {
159-
const result = await obj.fetch("/put", {
159+
const result = await obj.fetch(OB_ENDPOINT + "/put", {
160160
method: "POST",
161161
body: JSON.stringify(payload),
162162
headers: {

0 commit comments

Comments
 (0)