Oddbean new post about | logout
 Nuxt Server-Side Proxy for Open Weather API: A Solution for CORS Issues

Nuxt, a popular JavaScript framework, has introduced a server-side proxy feature that resolves Cross-Origin Resource Sharing (CORS) issues when using the Open Weather API. This issue arises when making API calls from a web application in a browser, as the browser blocks the request due to the lack of necessary CORS headers.

To overcome this limitation, developers can utilize Nuxt's server-side proxy by creating a file in the API folder on the Nuxt server directory. This setup enables the handling of API requests and simplifies the URL while keeping the API key secure.

This solution provides an efficient way to resolve CORS issues without requiring control over the Open Weather API server. It also highlights the benefits of using Nuxt, such as reduced code complexity and enhanced security features.

Source: https://dev.to/ratul16/nuxt-server-side-proxy-for-open-weather-api-577a