Skip to content

cors header#32

Open
rdavoli wants to merge 5 commits intomasterfrom
localbackend
Open

cors header#32
rdavoli wants to merge 5 commits intomasterfrom
localbackend

Conversation

@rdavoli
Copy link

@rdavoli rdavoli commented Oct 23, 2020

Fixes #36

Overview

Changes for running the backend outside the cloud.

@rdavoli rdavoli requested a review from filipecorrea October 23, 2020 12:40

const translation = await retrieveData(language, 'translations', { signed: signedProcessedText.hash })

if (!translation) throw new NotFoundError()
Copy link
Contributor

Choose a reason for hiding this comment

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

It's important to keep this validation error.

Copy link
Author

Choose a reason for hiding this comment

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

In this case, shouldn't we just return no translation and let the backend handle this and show an alert to the user that no translation was found?

As our database is still small, most phrases will return no translation.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the backend repo and NotFoundError is equal to no translation was found.

translations.retrieve(value.params.language, sanitize(value.query.text))
.then(response => {
res.locals = response
res.set('Access-Control-Allow-Origin', '*')
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried using localhost instead of *?

Copy link
Contributor

@filipecorrea filipecorrea left a comment

Choose a reason for hiding this comment

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

We should revert the changes on src/controllers/translations/retrieve.js, there's no need for those changes in this pull request.

ALLOWED_ORIGINS=http://localhost:3001
```


Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of setting ALLOWED_ORIGINS as mandatory, can we set it to http://localhost:3001 by default and move the update instruction to the Customize section bellow?

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.

2 participants