ldn-inbox-server 1.8.6 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +20 -15
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -78,7 +78,10 @@ function doInboxOPTIONS(req,res,opts) {
|
|
|
78
78
|
metadata['Allow'] = allow.join(",");
|
|
79
79
|
|
|
80
80
|
logger.debug(metadata);
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
res.setHeader('Access-Control-Allow-Origin','*');
|
|
83
|
+
res.setHeader('Access-Control-Allow-Headers','*');
|
|
84
|
+
|
|
82
85
|
for (let property in metadata) {
|
|
83
86
|
if (property !== 'Content-Type') {
|
|
84
87
|
res.setHeader(property,metadata[property]);
|
|
@@ -143,16 +146,18 @@ function doInboxHEAD(req,res,opts) {
|
|
|
143
146
|
|
|
144
147
|
if (pathItem === '/') {
|
|
145
148
|
const meta = getBody(`${id}.meta`,opts);
|
|
146
|
-
|
|
149
|
+
|
|
150
|
+
res.setHeader('Access-Control-Allow-Origin','*');
|
|
151
|
+
res.setHeader('Access-Control-Allow-Headers','*');
|
|
152
|
+
res.setHeader('Content-Type','application/ld+json');
|
|
153
|
+
|
|
147
154
|
if (meta) {
|
|
148
155
|
const metadata = JSON.parse(meta);
|
|
149
156
|
for (let property in metadata) {
|
|
150
157
|
res.setHeader(property,metadata[property]);
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
|
-
|
|
154
|
-
res.setHeader('Content-Type','application/ld+json');
|
|
155
|
-
}
|
|
160
|
+
|
|
156
161
|
res.writeHead(200);
|
|
157
162
|
res.end();
|
|
158
163
|
return;
|
|
@@ -169,15 +174,14 @@ function doInboxHEAD(req,res,opts) {
|
|
|
169
174
|
|
|
170
175
|
const meta = getBody(`${id}.meta`,opts);
|
|
171
176
|
|
|
177
|
+
res.setHeader('Content-Type','application/ld+json');
|
|
178
|
+
|
|
172
179
|
if (meta) {
|
|
173
180
|
const metadata = JSON.parse(meta);
|
|
174
181
|
for (let property in metadata) {
|
|
175
182
|
res.setHeader(property,metadata[property]);
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
|
-
else {
|
|
179
|
-
res.setHeader('Content-Type','application/ld+json');
|
|
180
|
-
}
|
|
181
185
|
|
|
182
186
|
res.writeHead(200);
|
|
183
187
|
res.end();
|
|
@@ -206,16 +210,16 @@ function doInboxGET_Index(req,res,opts) {
|
|
|
206
210
|
};
|
|
207
211
|
|
|
208
212
|
const meta = getBody(`.meta`,opts);
|
|
209
|
-
|
|
213
|
+
|
|
214
|
+
res.setHeader('Access-Control-Allow-Origin','*');
|
|
215
|
+
res.setHeader('Content-Type','application/ld+json');
|
|
216
|
+
|
|
210
217
|
if (meta) {
|
|
211
218
|
const metadata = JSON.parse(meta);
|
|
212
219
|
for (let property in metadata) {
|
|
213
220
|
res.setHeader(property,metadata[property]);
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
|
-
else {
|
|
217
|
-
res.setHeader('Content-Type','application/ld+json');
|
|
218
|
-
}
|
|
219
223
|
|
|
220
224
|
res.writeHead(200);
|
|
221
225
|
res.end(JSON.stringify(result,null,2));
|
|
@@ -229,15 +233,15 @@ function doInboxGET_Read(req,res,opts) {
|
|
|
229
233
|
if (result && opts['inboxPublic'] == 1) {
|
|
230
234
|
const meta = getBody(`${id}.meta`,opts);
|
|
231
235
|
|
|
236
|
+
res.setHeader('Access-Control-Allow-Origin','*');
|
|
237
|
+
res.setHeader('Content-Type','application/ld+json');
|
|
238
|
+
|
|
232
239
|
if (meta) {
|
|
233
240
|
const metadata = JSON.parse(meta);
|
|
234
241
|
for (let property in metadata) {
|
|
235
242
|
res.setHeader(property,metadata[property]);
|
|
236
243
|
}
|
|
237
244
|
}
|
|
238
|
-
else {
|
|
239
|
-
res.setHeader('Content-Type','application/ld+json');
|
|
240
|
-
}
|
|
241
245
|
|
|
242
246
|
res.writeHead(200);
|
|
243
247
|
res.end(result);
|
|
@@ -279,6 +283,7 @@ function doInboxPOST(req,res,opts) {
|
|
|
279
283
|
});
|
|
280
284
|
req.on('end',() => {
|
|
281
285
|
logger.debug(postData);
|
|
286
|
+
res.setHeader('Access-Control-Allow-Origin','*');
|
|
282
287
|
if (checkBody(postData,opts)) {
|
|
283
288
|
const id = storeBody(postData,opts);
|
|
284
289
|
storeMetadata(id,opts);
|