#community-help

Changing Path for Typesense Server Configuration

TLDR Karthik wanted to change the path in Typesense server config. Jason suggested updating the nodes and using Nginx reverse proxy for the desired configuration.

Powered by Struct AI
14
6mo
Solved
Join the chat
Mar 22, 2023 (6 months ago)
Karthik
Photo of md5-b7a258bf917f26602c9d5efc88bfc6f5
Karthik
03:19 PM
Jason, Is there any way to change the path from this to <http://localhost:8108/multi_search?x-typesense-api-key=xyz> this <http://localhost:8108/typesense/multi_search?x-typesense-api-key=xyz>

import TypesenseInstantsearchAdapter from "typesense-instantsearch-adapter";

let TYPESENSE_SERVER_CONFIG = {
  apiKey: "xyz", 
  nodes: [
    {
      host: "localhost",
      port: 8108,
      protocol: "http",
    },
  ],
  connectionTimeoutSeconds: 1,
  numRetries: 8,
};

export const typesenseAdapter = new TypesenseInstantsearchAdapter({
  server: TYPESENSE_SERVER_CONFIG,
  additionalSearchParameters: {
    query_by: "CAS_ID,Synonyms,Molecular_Weight",
    queryByWeights: "4,2,2",
    numTypos: 3,
    typoTokensThreshold: 1,
  },
});

export const searchClient = typesenseAdapter.searchClient;

above code, I wrote in next.js - typesenseadapter.js
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:36 PM
You can update the nodes config to this:

nodes: [
    {
      host: "localhost",
      path: "/typesense",
      port: 8108,
      protocol: "http",
    },
Karthik
Photo of md5-b7a258bf917f26602c9d5efc88bfc6f5
Karthik
03:49 PM
after adding the prop path I am getting an error - 400 { "message": "Not Found"}
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:54 PM
Could you look at the browser’s network inspector and share the actual path being generated?
03:54
Jason
03:54 PM
Wait do you already have Typesense running behind <http://localhost:8108/typesense/> via a reverse proxy?
Karthik
Photo of md5-b7a258bf917f26602c9d5efc88bfc6f5
Karthik
03:59 PM
I am trying on my local system Linux, and also 8108 port is running on my system
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:00 PM
See our previous thread about first running Typesense on that path via a reverse proxy: https://typesense-community.slack.com/archives/C01P749MET0/p1679094420084709
04:00
Jason
04:00 PM
Only once you have that working, will changing the config in the adapter work
Karthik
Photo of md5-b7a258bf917f26602c9d5efc88bfc6f5
Karthik
04:01 PM
Ok
04:02
Karthik
04:02 PM
I will try to repopulate the data with new configuration using typesense npm
08:28
Karthik
08:28 PM
Jason how can I add a path to the typesense server configuration
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:57 PM
Typesense does not support this natively
08:57
Jason
08:57 PM
So it will only listen to the root path
08:57
Jason
08:57 PM
You have to put nginx in front of Typesense if you want to serve from a sub-path