// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import axios from 'axios';
import { Cookies } from 'react-cookie';
import cookie from 'cookie';
import moment from 'moment';
import jwt from 'jsonwebtoken';

import { cors } from '../../../lib/cors';

export default async function handler(req, res) 
{
	await cors(req, res);
	let { token } = req.body;

	if(token !== undefined && token !== null)
	{
		console.log("API", "offstage", `${ process.env.NEXT_PUBLIC_API_HOST }/api/user/check/`);

		await axios.post(`${ process.env.NEXT_PUBLIC_API_HOST }/api/user/check/`, {
			token, 
		})
		.then((api_response) => 
		{
			console.log("RESPONSE");
			console.log(api_response.data);

			res.status(200).send(api_response.data);
		})
		.catch((error) => 
		{
			console.log("error");
			console.error(error);

			res.status(403).json();
		});
	}
	else
	{
		res.status(404).json();
	}
}