-
Notifications
You must be signed in to change notification settings - Fork 230
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
Conversation
Your Render PR Server URL is https://appwrite-io-docker-pr-541.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cmlfo7icn0vc73e8jbeg. |
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Co-authored-by: Bradley Schofield <ionicisere@gmail.com>
Co-authored-by: Bradley Schofield <ionicisere@gmail.com>
@LauraDuRy & @PineappleIOnic is there anything holding this article from being posted? |
There was a problem hiding this 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
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. |
There was a problem hiding this comment.
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** |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ##
There was a problem hiding this 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch 😆
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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. |
There was a problem hiding this comment.
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.
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. |
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.)