wph-proxy-next

1.3.21 • Public • Published

Proxy with NextJS

Required dependencies

npm install cookies-next

Environment variables

  • Need to add following environment variables to your NextJS App
NEXT_PUBLIC_API_URL=your_api_url
NEXT_PUBLIC_API_TOKEN=your_api_token

Setup script

  • Create a file named setup.js at root folder (or anywhere in you project)
  • Copy following code and paste into the file
const {initApiInstance, generateApiRoutes} = require('wph-proxy-next');

initApiInstance(process.env.NEXT_PUBLIC_API_URL, process.env.NEXT_PUBLIC_API_TOKEN);

generateApiRoutes(path.join(__dirname, "your-target-directory"));

Run script

  1. Add a custom script to package.json to execute setup.js file

For example:

"start": "node setup.js"
  1. Run this script before you build your NextJS App to populate api handlers

Readme

Keywords

none

Package Sidebar

Install

npm i wph-proxy-next

Weekly Downloads

3

Version

1.3.21

License

ISC

Unpacked Size

58.1 kB

Total Files

52

Last publish

Collaborators

  • kimthanh932000
  • phanhien.kamora
  • hieupham2220
  • hunglpkamora