JedPapa / spotify-web-player

0 stars 0 forks source link

Cannot GET/ #1

Open JedPapa opened 3 weeks ago

JedPapa commented 3 weeks ago

Cannot GET/ message on http://localhost:3000/auth/login/. There must be an issue with the index.js file in the server.

const express = require('express')
const request = require('request');
const dotenv = require('dotenv');

const port = 5000

let access_token = ''

dotenv.config()

var spotify_client_id = process.env.SPOTIFY_CLIENT_ID
var spotify_client_secret = process.env.SPOTIFY_CLIENT_SECRET

var spotify_redirect_uri = 'http://localhost:3000/auth/callback'

var app = express();

app.get('/auth/login', (req, res) => {

    var scope = "streaming user-read-email user-read-private"
    var state = generateRandomString(16);

    var auth_query_parameters = new URLSearchParams({
        response_type: "code",
        client_id: spotify_client_id,
        scope: scope,
        redirect_uri: spotify_redirect_uri,
        state: state
    })

    res.redirect('https://accounts.spotify.com/authorize/?' + auth_query_parameters.toString());
})

app.listen(port, () => {
    console.log('Listening at http://localhost:${port}')
})
JedPapa commented 2 weeks ago

The error changed to issue #2

JedPapa commented 2 weeks ago

This error was replaced by issue #2 , which was due to the server not being active at runtime. Case resolved. Back to this error.