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

Cors blog #541

Merged
merged 19 commits into from
Jan 30, 2024
Merged

Cors blog #541

merged 19 commits into from
Jan 30, 2024

Conversation

divanov11
Copy link
Contributor

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Copy link

render bot commented Jan 19, 2024

@divanov11 divanov11 requested a review from LauraDuRy January 19, 2024 22:55
featured: false
---

I want to address an issue I've seen popping up on stack overflow and the appwrite discord server and address some of the reasons you may be getting this error, and walk you through some of the steps you can take to try and resolve it as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

Capitalize Stack Overflow Appwrite and Discord

Copy link
Contributor

Choose a reason for hiding this comment

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

@divanov11 Take a look here at Laura's comments.


Without diving deep into the topic, CORS (Cross-Origin Resource Sharing ) is a mechanism which allows a server to specify which origins can access it. By origins I mean URL. Basically, site A, our server sitting at `myapi.com` won't allow request coming from site B, our client sitting at `myfrontend.com`.

This happens because our server has not added site B, `myfrontend.com` to it's list of allowed origins, therefor any request coming from a URL that is not listed in our servers allowed origins will be rejected by our CORS policy. The solution in this case would be to simply add `myfrontend.com` to the list of allowed origins.
Copy link
Contributor

Choose a reason for hiding this comment

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

therefor should be therefore?


### 1 - Origin not set in console

First, you'll want to check your appwrite console to make sure you have added a hostname and are making a request from the correct hostname. Make sure you have added a platform in your appwrite console by going to the "overview" tab, select your platform (Add one if you have not yet) and then ensure you have added a hostname.
Copy link
Contributor

Choose a reason for hiding this comment

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

capatilize Appwrite and Console


In most cases the issues people face have to do with one of the above reasons listed and can be solved with the given suggestions. However, if you are still running into issues I’ll keep an ongoing list of other possibilities and things to check for.

- Disabled CORS in browser. (I’ve seen people have this issue with browser extensions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add another line with resources:

  • docs
  • Discord
  • YouTube

LauraDuRy and others added 2 commits January 23, 2024 11:40
Co-authored-by: Bradley Schofield <ionicisere@gmail.com>
Co-authored-by: Bradley Schofield <ionicisere@gmail.com>
@divanov11
Copy link
Contributor Author

@LauraDuRy & @PineappleIOnic is there anything holding this article from being posted?

Copy link
Contributor

@PineappleIOnic PineappleIOnic left a comment

Choose a reason for hiding this comment

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

On a code level it looks good to me

@LauraDuRy
Copy link
Contributor

Added correct youtube link, all good now

featured: false
---

I want to address an issue I've seen popping up on stack overflow and the appwrite discord server and address some of the reasons you may be getting this error, and walk you through some of the steps you can take to try and resolve it as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

@divanov11 Take a look here at Laura's comments.


The error message you'll see in your console when trying to make a request to an Appwrite backend will look something like this: `Access blocked by CORS policy.`

## **Understanding CORS**
Copy link
Contributor

Choose a reason for hiding this comment

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

We start with # in the markdown -> It will be transformed to ## Please un bold the heading.

2. Origin is set incorrectly
3. Bad ID on request

### 1 - Origin not set in Console
Copy link
Contributor

@gewenyu99 gewenyu99 Jan 29, 2024

Choose a reason for hiding this comment

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

Move all you headings on level higher

## -> #

### -> ##

We render # as ##

Copy link
Contributor

@Kilo-Loco Kilo-Loco left a comment

Choose a reason for hiding this comment

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

Great read! Made some suggested changes.

Copy link
Contributor

@Kilo-Loco Kilo-Loco Jan 29, 2024

Choose a reason for hiding this comment

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

Typo: Server
nit: I'm wondering if we could use a different font to increase readability. This diagram is extremely helpful to people learning about CORs but people with any level of vision impairment may have difficulty reading this particular font. That said, this visualized architecture on an Appwrite blog is a signature that says this is a "Dennis Ivy" blog which is always a good read.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I fixed it in the video before release but forgot to update the blog image. I agree with the font issue. I'm using Excalidraw at the moment so I'll see if I can add custom fonts


## **Understanding CORS**

Before we start debugging this, let's talk about what CORS error is.
Copy link
Contributor

Choose a reason for hiding this comment

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

The following section teaches the reader what CORs is before referring to the error.

Suggested change
Before we start debugging this, let's talk about what CORS error is.
Before we start debugging this, let's talk about what CORS is.


### 1 - Origin not set in Console

First, you'll want to check your Appwrite Console to make sure you have added a hostname and are making a request from the correct hostname. Make sure you have added a platform in your Appwrite console by going to the "overview" tab, select your platform (Add one if you have not yet), and then ensure you have added a hostname.
Copy link
Contributor

Choose a reason for hiding this comment

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

Overview should be capitalized in this context.

Suggested change
First, you'll want to check your Appwrite Console to make sure you have added a hostname and are making a request from the correct hostname. Make sure you have added a platform in your Appwrite console by going to the "overview" tab, select your platform (Add one if you have not yet), and then ensure you have added a hostname.
First, you'll want to check your Appwrite Console to make sure you have added a hostname and are making a request from the correct hostname. Make sure you have added a platform in your Appwrite console by going to the "Overview" tab, select your platform (Add one if you have not yet), and then ensure you have added a hostname.

@gewenyu99 gewenyu99 merged commit 724d8e6 into main Jan 30, 2024
1 check passed
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.

5 participants