<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: fireWinters</title>
    <description>The latest articles on DEV Community by fireWinters (@firewinters).</description>
    <link>https://dev.to/firewinters</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F687945%2F78dcfc72-27df-4750-addd-7dadf8df4ae1.png</url>
      <title>DEV Community: fireWinters</title>
      <link>https://dev.to/firewinters</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/firewinters"/>
    <language>en</language>
    <item>
      <title>Introduction to CORS (Cross-Origin Resource Sharing) What is CORS?</title>
      <dc:creator>fireWinters</dc:creator>
      <pubDate>Wed, 13 Nov 2024 15:36:22 +0000</pubDate>
      <link>https://dev.to/firewinters/introduction-to-cors-cross-origin-resource-sharingwhat-is-cors-2l6f</link>
      <guid>https://dev.to/firewinters/introduction-to-cors-cross-origin-resource-sharingwhat-is-cors-2l6f</guid>
      <description>&lt;p&gt;CORS, or Cross-Origin Resource Sharing, is a security feature implemented by web browsers that allows or restricts web applications from making requests to a domain different from the one that served the web page. In simple terms, CORS determines whether resources on one domain can be accessed by a web page from another domain.&lt;/p&gt;

&lt;p&gt;By default, web browsers enforce the same-origin policy, which blocks web pages from making requests to a different domain than the one that served the page. This is done to prevent malicious websites from accessing sensitive data on other websites. However, sometimes web applications need to request resources from a different origin (domain, protocol, or port), which is where CORS comes into play.&lt;/p&gt;

&lt;p&gt;CORS in Action&lt;/p&gt;

&lt;p&gt;When a web application on one domain needs to request data from another domain, it sends an HTTP request with specific headers that indicate the origin of the request. The server that hosts the requested resource must then decide whether to allow the request by sending appropriate CORS headers in the response.&lt;/p&gt;

&lt;p&gt;For example, if you are building a frontend application hosted on &lt;a href="http://example.com" rel="noopener noreferrer"&gt;http://example.com&lt;/a&gt;, and it needs to fetch data from &lt;a href="http://api.example2.com" rel="noopener noreferrer"&gt;http://api.example2.com&lt;/a&gt;, CORS headers allow the server at api.example2.com to specify whether it will allow requests from example.com.&lt;/p&gt;

&lt;p&gt;Common Use Cases&lt;/p&gt;

&lt;p&gt;CORS is typically needed in the following scenarios:&lt;/p&gt;

&lt;p&gt;Third-party API Access: Many modern web applications rely on external APIs for services like authentication, payment processing, or social media integration. CORS is necessary when these APIs are hosted on different domains.&lt;/p&gt;

&lt;p&gt;Frontend-Backend Communication: In cases where the frontend and backend of a web application are hosted on different domains or subdomains, CORS is used to allow communication between them.&lt;/p&gt;

&lt;p&gt;CDN (Content Delivery Networks): Websites often use CDNs to serve static assets like images, stylesheets, or JavaScript files. CORS allows the main site to request these resources from a CDN hosted on a different origin.&lt;/p&gt;

&lt;p&gt;Key Parameters and Indicators in CORS&lt;/p&gt;

&lt;p&gt;Access-Control-Allow-Origin: This header is the most important in CORS and indicates which origins are permitted to access the resource. It can be set to:&lt;/p&gt;

&lt;p&gt;A specific origin (Access-Control-Allow-Origin: &lt;a href="https://example.com" rel="noopener noreferrer"&gt;https://example.com&lt;/a&gt;)&lt;br&gt;
A wildcard (Access-Control-Allow-Origin: *), which allows any origin to access the resource. However, this is not allowed for requests that include credentials.&lt;br&gt;
Access-Control-Allow-Methods: Specifies which HTTP methods (such as GET, POST, PUT, DELETE) are allowed when accessing the resource. For example:&lt;br&gt;
Access-Control-Allow-Methods: GET, POST, PUT&lt;/p&gt;

&lt;p&gt;Access-Control-Allow-Headers: Lists the HTTP headers that can be used when making the actual request. For instance, if the request includes a custom header like X-Custom-Header, it should be specified here:&lt;br&gt;
Access-Control-Allow-Headers: X-Custom-Header, Content-Type&lt;/p&gt;

&lt;p&gt;Access-Control-Allow-Credentials: Indicates whether the request can include credentials such as cookies, HTTP authentication, or client-side certificates. This is important for APIs that require authentication. For example: Access-Control-Allow-Credentials: true&lt;/p&gt;

&lt;p&gt;Access-Control-Expose-Headers: Specifies which headers the browser should expose to the requesting client. By default, browsers only expose a limited set of headers like Cache-Control and Content-Type, but Access-Control-Expose-Headers can make additional headers available.&lt;/p&gt;

&lt;p&gt;Access-Control-Max-Age: Defines how long the results of a preflight request (see below) can be cached by the browser. It helps improve performance by reducing the number of preflight requests. For example:&lt;br&gt;
Access-Control-Max-Age: 86400 (24 hours)&lt;/p&gt;

&lt;p&gt;Preflight Requests: For certain types of requests, especially those that modify server data (such as PUT or DELETE), browsers send a preflight request using the HTTP OPTIONS method. This checks with the server whether the actual request is safe to send. The server's response to the preflight request determines whether the browser will proceed with the actual request.&lt;/p&gt;

&lt;p&gt;When Do You Need CORS?&lt;/p&gt;

&lt;p&gt;CORS is required when:&lt;/p&gt;

&lt;p&gt;Cross-origin requests are made: If your frontend and backend are served from different domains or ports, or if you're accessing external APIs from your application.&lt;/p&gt;

&lt;p&gt;Accessing resources hosted on a CDN or third-party service: For instance, if you load fonts, images, or other assets from a CDN, the server must include CORS headers to allow your site to access them.&lt;/p&gt;

&lt;p&gt;Security concerns: While enabling CORS allows cross-origin requests, it should be carefully configured to avoid opening up your application to malicious attacks. Only trusted origins should be allowed, and sensitive operations should be protected with additional security measures like authentication tokens.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;CORS is a crucial mechanism for ensuring the safe and controlled sharing of resources across different origins. Properly configured, it helps enable modern web applications to interact with third-party services and APIs while protecting users from security risks. Understanding how to configure CORS headers and knowing when and why they are needed is essential for any web developer working with APIs, CDNs, or multi-domain applications.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>security</category>
    </item>
    <item>
      <title>What are the differences between the Composition API used in Vue 3.0 and the Options API used in Vue 2.x?</title>
      <dc:creator>fireWinters</dc:creator>
      <pubDate>Thu, 29 Aug 2024 15:00:38 +0000</pubDate>
      <link>https://dev.to/firewinters/what-are-the-differences-between-the-composition-api-used-in-vue-30-and-the-options-api-used-in-vue-2x-2b7e</link>
      <guid>https://dev.to/firewinters/what-are-the-differences-between-the-composition-api-used-in-vue-30-and-the-options-api-used-in-vue-2x-2b7e</guid>
      <description>&lt;p&gt;The differences between Vue 3.0's Composition API and Vue 2.x's Options API are as follows:&lt;/p&gt;

&lt;p&gt;Code Organization:&lt;/p&gt;

&lt;p&gt;Composition API: Uses the setup function to centralize the management of a component's state and logic, making the code easier to read and maintain.&lt;br&gt;
Options API: Distributes component state and logic across different options such as data, methods, computed, and watch.&lt;br&gt;
Logic Reuse and Composition:&lt;/p&gt;

&lt;p&gt;Composition API: Facilitates easier extraction and reuse of component logic without needing mixins or other abstraction mechanisms.&lt;br&gt;
Options API: Typically requires the use of mixins or higher-order components to reuse logic, which can lead to naming conflicts and tight coupling between components.&lt;br&gt;
Type Support:&lt;/p&gt;

&lt;p&gt;Composition API: Being function-based, it integrates more easily with TypeScript (functional programming).&lt;br&gt;
Options API: May require additional type declarations and decorators.&lt;br&gt;
Reactivity Declaration:&lt;/p&gt;

&lt;p&gt;Composition API: Explicitly creates reactive state using ref and reactive.&lt;br&gt;
Options API: Reactive state is typically created implicitly within the data option.&lt;br&gt;
Lifecycle Hooks:&lt;/p&gt;

&lt;p&gt;Composition API: Lifecycle hooks like onMounted and onUpdated exist as functions within the setup function.&lt;br&gt;
Options API: Lifecycle hooks are defined as component options, such as mounted and updated.&lt;br&gt;
Template Usage:&lt;/p&gt;

&lt;p&gt;Composition API: All variables and methods returned by the setup function can be directly used in the template.&lt;br&gt;
Options API: Data and methods in the template need to be defined separately in data, computed, methods, etc.&lt;br&gt;
Dependency Tracking:&lt;/p&gt;

&lt;p&gt;Composition API: Provides more granular dependency tracking, where only the actual state in use triggers component updates.&lt;br&gt;
Options API: May cause unnecessary component re-renders in certain scenarios.&lt;br&gt;
Code Splitting and On-Demand Import:&lt;/p&gt;

&lt;p&gt;Composition API: Facilitates easier code splitting and on-demand imports since related logic can be more easily organized together.&lt;br&gt;
Options API: Code splitting and on-demand imports are usually more complex and redundant.&lt;br&gt;
Readability and Maintainability:&lt;/p&gt;

&lt;p&gt;Composition API: For complex components, it is usually easier to understand and maintain due to the centralized logic.&lt;br&gt;
Options API: For simple components, it may be more intuitive as the API is dispersed.&lt;br&gt;
Community and Ecosystem:&lt;/p&gt;

&lt;p&gt;Composition API: As a new feature in Vue 3, it may take time to build an ecosystem around it.&lt;br&gt;
Options API: Already has a mature community and abundant resources.&lt;br&gt;
Both have their advantages and disadvantages, and Vue 3 also supports mixing the two, allowing developers to choose the API that best suits their specific needs.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>how to change the author's name in committed git records.</title>
      <dc:creator>fireWinters</dc:creator>
      <pubDate>Sun, 18 Aug 2024 13:32:46 +0000</pubDate>
      <link>https://dev.to/firewinters/how-to-change-the-authors-name-in-committed-git-records-39jk</link>
      <guid>https://dev.to/firewinters/how-to-change-the-authors-name-in-committed-git-records-39jk</guid>
      <description>&lt;p&gt;Today I reviewed how to change the author's name in a committed git record.how to fix I've deleted the specific branch on GitHub, but I still see it in my Git records locally. &lt;br&gt;
1.Change the author's name.&lt;br&gt;
git filter-branch is used as an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git filter-branch --env-filter '
OLD_EMAIL="old.email@example.com"
CORRECT_NAME="New Name"
CORRECT_EMAIL="new.email@example.com"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it works.We should force push our local branch to github.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push --force origin branch-name

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Synchronize local and remote git branch records&lt;br&gt;
I've deleted the branch-name branch on GitHub, I still see it in my Git records locally. This can happen because my local repository retains references to the deleted branch. &lt;br&gt;
Here is a solution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git fetch --prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I still have a lot to learn&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
    </item>
    <item>
      <title>How to find cancer signaling receptor？</title>
      <dc:creator>fireWinters</dc:creator>
      <pubDate>Wed, 27 Jul 2022 05:34:00 +0000</pubDate>
      <link>https://dev.to/firewinters/how-to-find-cancer-signaling-receptor-5ceo</link>
      <guid>https://dev.to/firewinters/how-to-find-cancer-signaling-receptor-5ceo</guid>
      <description>&lt;p&gt;I assume that every cell has a special receptor, we call it cancer cell receptor, when the cell becomes cancerous, this receptor is active and can migrate, infiltrate, spread to all parts of the body, and if it can be cured, then It is this receptor that is turned off and is in a dormant state. When the cancer is advanced and the cells are severely damaged, the receptor is also destroyed, and the cancer process cannot be reversed. How to find this receptor?&lt;br&gt;
    Here is just a hypothesis, how to verify this hypothesis requires a well-designed experimental plan.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
