Avoid CORS issues by using API Routes from Next.js

Overview

CORS Demo

Avoid CORS issues by using API Routes from Next.js.

Get Started

  1. Clone the repo git clone [email protected]:gregrickaby/cors-demo.git
  2. CD into cors-demo
  3. Start the dev server npm run dev
  4. Visit any of the pages in the /demo directory

ENV Vars

  1. Create a new file named .env.local
  2. Add the following ENV Vars to .env.local
# This ENV variable is passed to the user's web browser.
NEXT_PUBLIC_UNSPLASH_ACCESS_KEY='<your unsplash access key>'

# This ENV variable is not.
UNSPLASH_ACCESS_KEY='<your unsplash access key>'
You might also like...

🚏 Routes for Next.js

🚏 Routes for Next.js

next-route-map 🚏 next-route-map allows you to define a route map. It automatically generates page modules that forward original modules in build time

Sep 24, 2022

🤖 GitHub Action which creates Issues from comments in your code

🤖 GitHub Action which creates Issues from comments in your code

todo-issue[action] Disclosure Huge thanks to JasonEtco! After he decided to shut down his todo[bot] I've looked around for alternatives but decided to

Dec 11, 2022

Add issues to projects (beta)

Add Issue/PR to Project (BETA) ➕ This GitHub action adds issues or pull requests to a Project (beta). Usage Create a workflow (eg: .github/workflows/o

Aug 12, 2022

🌱 Ethereum provider solution for Dapp&Wallets, 🏷 If you have good suggestions, please submit issues

🌱 Ethereum provider solution for Dapp&Wallets,  🏷 If you have good suggestions, please submit issues

English | 简体中文 | 日本 ETH Wallet Modal An Ethereum Provider Solution for Integrated Wallets and Dapps ⚠️ Notice If you need to reduce unnecessary import

Dec 19, 2022

Automate adding issues and pull requests to GitHub projects (beta)

actions/add-to-project Use this action to automatically add the current issue or pull request to a GitHub project. Note that this is for GitHub projec

Jan 3, 2023

This plugin allows you to track the progress of Atlassian Jira issues from your Obsidian notes.

This plugin allows you to track the progress of Atlassian Jira issues from your Obsidian notes.

Obsidian jira-issue This plugin allows you to track the progress of Atlassian Jira issues from your Obsidian notes. Usage Configuration Use the plugin

Dec 30, 2022

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms

CodeTogether is a platform that aims to bring all the developers and coders together to appreciate collaborative coding by resolving issues faced by programmers on normal IDEs/platforms. It allows developers to communicate with their fellow developers or collaborators through online voice call and realtime chat. Besides, the whiteboard makes the framing of an algorithm easier by helping programmers working collaboratively to discuss and plan their approach together

Jan 20, 2022

Fixes code dependency issues 🤼‍♀️

Codependence 🤼‍♀️ Codependence is a JavaScript utility CLI or node tool for checking specified dependencies in a project to ensure dependencies are u

Dec 15, 2022

Add a table of contents to the sidebar of your GitHub issues and pull requests.

Add a table of contents to the sidebar of your GitHub issues and pull requests.

github-sidebar-jump-extension Getting started 🛠 Build locally Checkout the repository to your local machine Run npm install to install all required d

Sep 7, 2022
Comments
  • Bump next from 12.0.8 to 12.0.9

    Bump next from 12.0.8 to 12.0.9

    Bumps next from 12.0.8 to 12.0.9.

    Release notes

    Sourced from next's releases.

    v12.0.9

    This upgrade is completely backward-compatible and recommended for all users on versions below 12.0.9

    Vulnerable code could allow a bad actor to trigger a denial of service attack via the /${locale}/_next/ route for anyone running a Next.js app at version >= 12.0.0, and using built-in i18n routing functionality.

    How to Upgrade

    • We have released patch versions for both the stable and canary channels of Next.js.
    • To upgrade run npm install next@latest --save

    Impact

    • Affected: All of the following must be true to be affected by this CVE
      • Next.js versions between v12.0.0 and v12.0.9
      • Using next start or a custom server
      • Using the built-in i18n support
    • Not affected:
      • Deployments on Vercel (vercel.com) are not affected along with similar environments where invalid requests are filtered before reaching Next.js.

    We recommend everyone to upgrade regardless of whether you can reproduce the issue or not.

    How to Assess Impact

    If your server has seen requests to any route under the prefix /${locale}/_next/ that have triggered a heap overflow error, this was caused by the patched issue.

    What is Being Done

    As Next.js has grown in popularity and usage by enterprises, it has received the attention of security researchers and auditors. We are thankful to our users for their investigation and responsible disclosure of the original bug.

    We've landed a patch that ensures this is handled properly so the requested route no longer crashes and triggers a heap overflow.

    Regression tests for this attack were added to the i18n integration test suite

    • A public CVE was released.
    • We encourage responsible disclosure of future reports. Please email us at [email protected]. We are actively monitoring this mailbox.

    Core Changes

    • middlewares: limit process.env to inferred usage: #33186
    • update webpack: #33207
    • Abstract out native filesystem usage from the base server: #33226
    • use text data url instead of base64 for shorter encoding: #33218
    • chore(deps): upgrade postcss: #33142
    • Fix global process testing for the process polyfill: #33220
    • Update swc: #33201
    • improve full refresh overlay: #33301
    • Custom app for server components: #33149
    • Update yarn PnP tests and disable swc file reading for PnP: #33236
    • Base Http for BaseServer: #32999
    • Update swc: #33342

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 2
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump next from 12.0.10 to 12.1.0

    Bump next from 12.0.10 to 12.1.0

    Bumps next from 12.0.10 to 12.1.0.

    Release notes

    Sourced from next's releases.

    v12.1.0

    Core Changes

    • Relay Support in Rust Compiler: #33702
    • fix eslint link-passhref rule: #33857
    • update webpack: #33831
    • Flush buffered vitals metrics on page mount: #33867
    • fix problem with HMR when middleware and page reference the same node_module: #33873
    • Refactor page component getter in web server: #33759
    • update NextResponse default redirect status to 307 to match docs: #33505
    • Bug fix: dynamic page should not be interpreted as predefined page: #33808
    • Group streaming experimental apis: #33878
    • Encapsulate routing and initial hydration: #33875
    • Optimize offline condition judgment: #33238
    • Ensure external beforeFiles rewrites are handled with next/link: #33888
    • Fix parsing params for i18n optional route in minimal mode: #33896
    • Ensure browserslist extends works properly: #33890
    • Fix image cache race condition: #33883
    • Add support for Relay projects without artifactDirectory: #33918
    • fix: handle jsxspreadattribute in inline-script-id eslint rule: #32421
    • feat(next-swc): Update swc: #33724
    • Update to latest version of amphtml-validator: #33967
    • Warn in dev mode when script tags are added with next/head: #33968
    • Ensure optional chaining in swc matches babel: #33995
    • Use react-dom/server.browser in Node.js: #33950
    • Ensure external middleware rewrite is handled correctly: #33962
    • Update Terser to v5.10.0, fix minification issues: #33045
    • Warn in dev mode when stylesheets are added using next/head: #34004
    • Use ReadableStream in RenderResult: #34005
    • Fix suffix ordering while streaming: #34011
    • Don't use yarn if a package-lock.json file is found: #31926
    • Do not warn when application/ld+json scripts are used with next/head: #34021
    • Babel & next-swc: Fix exporting page config with AsExpression: #32702
    • Detect per page runtime config for functions manifest: #33945
    • Add JSDoc to config options: #32915
    • Update font-stylesheet-gathering-plugin.ts: #30709
    • Add decoratorMetadata flag if enabled by tsconfig: #32914
    • fix: data url handling in css-loader: #34034
    • Place 'charset' element at the top of : #28119
    • Fix detection of anchor click events inside svg: #23272
    • Allow passing nothing as custom jest config: #32328
    • Fixes #31240: Adding a recursive addPackagePath function in webpack-config: #31264
    • Require component rendered as child of Link to pass event to onClick handler: #27723
    • Allow scroll prevention on hash change: #31921
    • Add support for async fn / promise in next.config.js/.mjs: #33662
    • Fix lazyRoot functionality for next/image: #33933
    • Change SWC minify from beta to release candidate: #34056
    • Make Router state immutable: #33925
    • Stop exposing internal render and renderError methods from next/client: #34069
    • Add api-utils helper for testing: #34078

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
Owner
Greg Rickaby
Director of Engineering @WebDevStudios | Author & Editor @wiley
Greg Rickaby
next-graphql-server is a library for building production-grade GraphQL servers using Next.js with API Routes

next-graphql-server next-graphql-server is an easy to use Next.js library for creating performant GraphQL endpoints on top of Next.js API Routes. Star

Jakub Neander 82 Nov 21, 2022
💀 A bare-minimum solution to solve CORS problem via proxy API

?? CORS Hijacker A bare-minimum solution to solve CORS problem via proxy API Base URL https://cors-hijacker.vercel.app/ Get Get Basic HTML Endpoint: $

Irfan Maulana 35 Nov 4, 2022
Dead-simple CORS handling for any itty-router API (test with Cloudflare Workers, but works anywhere)!

Simple CORS-handling for any itty-router API. Designed on Cloudflare Workers, but works anywhere. Features Tiny. Currently ~600 bytes, with zero-depen

Kevin R. Whitley 6 Dec 16, 2022
Avoid setting up a project from scratch. Start using VRTTV 🎉

VRTTV Boilerplate Avoid setting up a project from scratch. Start using VRTTV ?? View Demo · Report Bug · Request Feature ?? What’s this? Are you tired

Diego Do Santos 32 Nov 24, 2022
Avoid use of dangerouslySetInnerHTML with this lightweight (2KB) function.

Avoid use of dangerouslySetInnerHTML with this lightweight (2KB) function. Can parse HTML strings into VDom trees, ready to render in your Preact components

James Hill 4 May 14, 2022
Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome).

TinySource Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome). Sn

null 81 Jan 3, 2023
Snipes Test Flight apps. Configurable & has the ability to use a burner account for checking the status to avoid bans.

TestFlight Sniper Snipes TestFlight beta apps. Configurable & has the ability to use a burner account for checking the status to avoid bans. Features

eternal 12 Dec 20, 2022
Dank Memer (Selfbot) Farm with slash commands support and random delays and breaks to avoid any suspicion

Slashy Slashy is a Dank Memer (Selfbot) Farm with slash commands support and random delays and breaks to avoid any suspicion. This is completely undet

Taha Gorme 16 Dec 30, 2022
Labels issues using OpenAI's Classification API powered by GPT-3 models!

OpenAI Issue Labeler ?? This GitHub action labels issues using OpenAI's Classification API powered by GPT-3 models! We are using curie as our completi

Austen Stone 11 Dec 21, 2022
It shows how to escape cross-origin issues for web client and API server using CloudFront routing.

AWS CloudFront의 URL Routing을 이용한 Web Client 및 API Server 구현 여기서는 CliendFront의 URL Routing을 이용하여 Web Client와 API Server를 구현하고자 합니다. Web Client는 Amazon

John Park 4 Nov 20, 2022