Skip to content

Commit

Permalink
cors
Browse files Browse the repository at this point in the history
  • Loading branch information
vimfn committed Aug 22, 2023
1 parent 31bc639 commit 484bc61
Show file tree
Hide file tree
Showing 5 changed files with 636 additions and 570 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
// sassOptions: {
// includePaths: [path.join(__dirname, "styles")],
// },

images: {
domains: ["cdn.discordapp.com", "arunava.tech", "hi.arunava.tech"],
},
Expand Down
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@
},
"dependencies": {
"@fontsource/jost": "^4.5.12",
"@fontsource/sen": "^4.5.3",
"@types/node": "^17.0.24",
"@fontsource/sen": "^4.5.9",
"@types/node": "^17.0.45",
"axios": "^0.26.1",
"next": "12.1.5",
"next-seo": "^4.29.0",
"nextjs-cors": "^2.1.2",
"react": "17.0.2",
"react-dom": "17.0.2",
"sass": "^1.49.10",
"sass": "^1.57.1",
"swr": "^1.3.0"
},
"devDependencies": {
"@commitlint/cli": "^16.0.1",
"@commitlint/config-conventional": "^16.0.0",
"@types/react": "^17.0.37",
"autoprefixer": "^10.4.0",
"commitlint": "^16.2.3",
"commitlint-config-gitmoji": "^2.2.5",
"@commitlint/cli": "^16.3.0",
"@commitlint/config-conventional": "^16.2.4",
"@types/react": "^17.0.52",
"autoprefixer": "^10.4.13",
"commitlint": "^16.3.0",
"commitlint-config-gitmoji": "^2.2.10",
"eslint": "8.4.1",
"eslint-config-next": "12.0.7",
"husky": "^7.0.4",
"postcss": "^8.4.4",
"prettier": "^2.5.1",
"prettier-plugin-tailwindcss": "^0.1.4",
"react-icons": "^4.3.1",
"tailwindcss": "^3.0.0",
"typescript": "^4.5.2"
"postcss": "^8.4.21",
"prettier": "^2.8.3",
"prettier-plugin-tailwindcss": "^0.1.13",
"react-icons": "^4.7.1",
"tailwindcss": "^3.2.4",
"typescript": "^4.9.4"
},
"version": "0.2.13"
}
10 changes: 10 additions & 0 deletions pages/api/now-playing.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { getNowPlaying } from "../../lib/spotify";
import NextCors from 'nextjs-cors';


export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const response = await getNowPlaying();

// You Probably don't need this, but in case you do, here's how to use it
await NextCors(req, res, {
// Options
methods: ['GET', 'HEAD', 'PUT', 'PATCH', 'POST', 'DELETE'],
origin: '*',
optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
});

if (response.status === 204 || response.status > 400) {
return res.status(200).json({ isPlaying: false });
}
Expand Down
Loading

1 comment on commit 484bc61

@vercel
Copy link

@vercel vercel bot commented on 484bc61 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.