![Node.js Node.js](/uploads/1/3/4/1/134119457/929899841.png)
I have a web app that allows people to generate a list of songs by artists that are related to a particular artist. I want to be able to connect to the user's Spotify account and create a playlist for them from that list of songs, but I need to get an access token. I have a developer account and client ID and am trying to work through the Authorization Flow, but it's not working for me. Instead, I get this error:
XMLHttpRequest cannot load https://accounts.spotify.com/authorize/?client_id=d137fe25b31c4f3ba9e29d85f…:3000/callback&scope=user-read-private%20user-read-email&state=34fFs29kd09. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
Reference the file that QuickStart builds for you and it will run your code. QuickStart can either run in dev mode, where it compiles the code when you reload the browser, or in production mode, where you compile it first and then run the pre-compiled file. For technical discussion of the Spotify API by web sites, web apps, mobile apps, or other third parties, and promotion of sites and apps using the Spotify API to enhance the use of Spotify. (Unofficial / Not affiliated with Spotify.). You need to have a Spotify account to begin. If you don't then go to and create one. You will also need to have NodeJS installed locally. I used version 12.14.1 while writing this post. When you have an account go to and click on the button to create a Client ID. You will be asked some questions about the app you're planning to build, and that. They asked me build a web app and didn't specify much so I began making it using Node.js. Turns out the hosting service they gave me has no Node.js support. It looks like it's designed for WordPress sites specifically and it comes with a mySQL database. I've created an app which works for Spotify Premium users only (PUT methods don't work for non-premium users according to Spotify's documentation). It's a ten-question interactive quiz where a playlist generates in your Spotify account, plays it and you have to guess the name of each song.
This is a portion of my
scripts.js
file (i'm using the spotify-web-api-js
node module):![Spotify Spotify](/uploads/1/3/4/1/134119457/880653332.png)
Spotify Node
According to my research, it's a CORS-related issue. Spotify free music download hack. I'm making edits to my ExpressJS server to remedy this cross-origin problem and installed the
cors
node module, but I'm still getting the same error. Node Js App
index.js
server:When I go to the URL in question directly through my browser, it gives me the expected 'Do you authorize this app to use your Spotify information' form. Spotify mobile app repeat button.
Run Node Js App
Should I require 'cors' in 'scripts.js' for it to work? Does anyone have any other suggestions?