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

Move gemini rating logic to server #14

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

devnook
Copy link
Collaborator

@devnook devnook commented Jul 8, 2024

  • Adds a Cloud function in /functions dir that serves Gemini powered ratings.
  • Removes gemini logic from the frontend

@devnook devnook requested a review from maudnals July 8, 2024 13:53
Copy link
Member

@tomayac tomayac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo one console.log() leftover.

functions.http('product-reviews-gemini-get-rating', async (req, res) => {
res.set('Access-Control-Allow-Origin', '*');
if (req.method === 'OPTIONS') {
console.log('is OPTIONS')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log('is OPTIONS')

return res.status(204).send('');
}

if (!req.body.review) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by comment: would it make sense to implement a few best practices here around making sure that calls only come from your own website? (e.g. checking referrer...). I know that this can easily be spoofed, but might be a good indicator for people looking at this that they should think about how to secure their API endpoints.

This might also be complete overkill here...

@andreban
Copy link
Member

@devnook this PR has conflicts and can't be merge. Is it still going to be updated or should it be closed?

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

Successfully merging this pull request may close these issues.

4 participants