Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can change GET to POST?[IDEA] #678

Open
melfebulu opened this issue Mar 18, 2024 · 1 comment
Open

can change GET to POST?[IDEA] #678

melfebulu opened this issue Mar 18, 2024 · 1 comment
Labels
upgrade New feature or request

Comments

@melfebulu
Copy link

melfebulu commented Mar 18, 2024

Describe the feature you'd like

A clear and concise description of what you want to happen. Include any relevant links or screenshots or inspiration.

hello, I check the source code in /src/khoj/interface/web/chat.html

here is use GET but not POST

let url =/api/chat?q=${encodeURIComponent(query)}&n=${resultsCount}&client=web&stream=true&conversation_id=${conversationID}&region=${region}&city=${city}&country=${countryName};

I asked gpt,so the answer is :

This line of code constructs a URL that includes the query parameters and other information collected from the front end. Then, this URL is used in a fetch() call, which effectively sends a GET request to the server. This process involves:

Retrieving the user input for the query.
Encoding the query content along with other relevant information (such as result count, client type, session ID, and geographical location information, etc.) into the URL's query string.
Using this URL to initiate a network request to the server-side corresponding API endpoint through the browser.
In this process, after receiving this GET request, the server processes it based on the request's parameters and returns the appropriate data.

If you want to change to using the POST method to submit information, you need to modify this part of the logic, create a request body, and then send this request body via a POST request, instead of appending all information in the query string of the URL. One advantage of doing this is that POST requests do not expose data in the URL, making them suitable for sending large amounts of data or sensitive information.

@melfebulu melfebulu added the upgrade New feature or request label Mar 18, 2024
@sabaimran
Copy link
Collaborator

Hey @melfebulu ! Was there a particular reason why you wanted to use POST over GET here? I certainly see your point, wouldn't mind switching over, but curious to hear if you hit a specific limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upgrade New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants