Roman Kovtun
03/17/2022, 8:28 PMenable cors
to allow me to control collection and document imports from my app, however, creating, or updating works fine nothing looks odd to me, but when I am trying to delete just a collection it doesnt allow me to do it. I tried to find a solution to it but it doesnt look like it exists in documentation as common issue, so decided to try slack community to see if anyone know what might I am doing wrong with it. I have regular call like () => client.collections("watch_march_17").delete()
but I am getting cors issue:
Access to XMLHttpRequest at '<http://localhost:8108/collections/watch_march_17?x-typesense-api-key=qp23Vu35PtddRVDC6sgCFN9SP7BPc5Z3Fh>' from origin '<http://localhost:3000>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I also tried typesense-dashboard
a small project that helps to play with collections, which actually works fine and I can delete collections, but I dont want to use it with production due to couple security reasons, anyway thanks again for further helpJason Bosco
03/17/2022, 8:29 PMRoman Kovtun
03/17/2022, 8:30 PMdocker run -p 8108:8108 -v/tmp/typesense-data:/data typesense/typesense:0.22.1 \
--data-dir /data --api-key=qp23Vu35PtddRVDC6sgCFN9SP7BPc5Z3Fh9gMuBy --enable-cors
Jason Bosco
03/17/2022, 8:32 PM() => client.collections("watch_march_17").delete()
from the browser?Roman Kovtun
03/17/2022, 8:34 PMconst SERVER_CONFIG = {
nodes: [{
host: process.env.typesenseHost,
port: process.env.typesensePort,
protocol: process.env.typesenseProtocol,
}],
apiKey: process.env.typesenseSearchApiKey,
numRetries: 8,
connectionTimeoutSeconds: 2,
}
export const TSAdapter = new TypesenseInstantsearchAdapter({
server: SERVER_CONFIG,
additionalSearchParameters: {
queryBy: 'brand,model,reference',
queryByWeights: '4,2,1',
numTypos: 1,
typoTokensThreshold: 1,
},
});
export default new Typesense.Client(Object.assign(
SERVER_CONFIG,
{
apiKey: process.env.typesenseAdminApiKey,
}
));
which does it job creating multiple collections and so, but not delete for some reason, I am actually updating image right, might be the version issue but I am not sureJason Bosco
03/17/2022, 8:35 PM0.23.0.rc47
?Jason Bosco
03/17/2022, 8:37 PMRoman Kovtun
03/17/2022, 8:43 PMRoman Kovtun
03/17/2022, 8:45 PMJason Bosco
03/17/2022, 8:48 PMRoman Kovtun
03/17/2022, 8:51 PMRoman Kovtun
03/17/2022, 8:51 PMRoman Kovtun
03/17/2022, 8:54 PMJason Bosco
03/17/2022, 8:59 PMcurl -sv -H "X-TYPESENSE-API-KEY: qp23Vu35PtddRVDC6sgCFN9SP7BPc5Z3Fh9gMuBy" \
-X DELETE \
"<http://localhost:8108/collections/watch_march_17>"
Roman Kovtun
03/17/2022, 10:00 PM> -X DELETE \
> "<http://localhost:8108/collections/watch_march_17>"
* Trying ::1:8108...
* Connected to localhost (::1) port 8108 (#0)
> DELETE /collections/watch_march_17 HTTP/1.1
> Host: localhost:8108
> User-Agent: curl/7.77.0
> Accept: */*
> X-TYPESENSE-API-KEY: qp23Vu35PtddRVDC6sgCFN9SP7BPc5Z3Fh9gMuBy
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: keep-alive
< access-control-allow-origin: *
< content-type: application/json; charset=utf-8
< transfer-encoding: chunked
<
* Connection #0 to host localhost left intact
{"created_at":1647545791,"default_sorting_field":"","fields":[{"facet":true,"index":true,"infix":false,"locale":"","name":"brand","optional":false,"sort":false,"type":"string"}],"name":"watch_march_17","num_documents":0,"symbols_to_index":[],"token_separators":[]}
Jason Bosco
03/17/2022, 10:36 PMaccess-control-allow-origin: *
returned by the server. So I wonder why the browser is complainingJason Bosco
03/17/2022, 10:40 PMAccess-Control-Allow-Methods
is by default set to allow GET HEAD POST requests. So may be that's why it's not working for DELETEsJason Bosco
03/17/2022, 10:40 PMAccess-Control-Allow-Methods
header on the server-side to get this to work.Jason Bosco
03/17/2022, 10:41 PMRoman Kovtun
03/17/2022, 11:23 PMRoman Kovtun
03/17/2022, 11:32 PMJason Bosco
03/17/2022, 11:33 PMJason Bosco
03/17/2022, 11:33 PMRoman Kovtun
03/18/2022, 12:34 AM