vercel

Mongoose .findOne() breaks when deployed

一个人想着一个人 提交于 2021-02-11 12:36:20
问题 I have Micro endpoints for my API that uses Mongoose. All of them work fine, except the one that uses .findOne(). This one returns the right data locally, but not when deployed to Now v2. Here is the endpoint: const { createError, run, send } = require("micro"); const mongoose = require("mongoose").set("debug", true); const mongooseConnect = require("./utils/mongooseConnect"); const Art = require("./schemas").art; mongooseConnect(); const art = async (req, res) => { console.log("hello world")

Call cloud functions without waiting for response

这一生的挚爱 提交于 2021-02-10 05:59:27
问题 Trying a little hack here with cloud functions but can't seem to figure out what the issue is. I'm currently using now.sh to host serverless functions and would like to call 1 function from another. Lets say I have 2 functions declared fetchData & setData . When the setData function is called it processes some data and then calls the fetchData function. export const setData = async (req: Request, res: Response) => { await axios.post( fetchDataEndpointUrl, { params: { key, }, }, ); return res

Pages with `getServerSideProps` can not be exported

本秂侑毒 提交于 2020-06-26 08:28:08
问题 I think i am making some kind of confusion here. According to the documentation, if i want Server Side Rendering (SSR) for the page i export the async function: getServerSideProps But if i do that i can't build the project for running either locally or now Zeit now. If i try build or deploy i get: Error for page /_error: pages with getServerSideProps can not be exported. See more info here: https://err.sh/next.js/gssp-export The link provided by the error says i can't export. But I used the

JSON.parse: unexpected character at line 1 column 1 of the JSON data when runing nextjs

为君一笑 提交于 2020-06-17 13:27:37
问题 My project suddenly start to give the following error, when accessing any page: JSON.parse: unexpected character at line 1 column 1 of the JSON data After rebuild the project from scratch i found out that the cause is the node path set on dev command, like this: //package.json file "NODE_PATH=. next" This is a common solution describe here to enable use of absolute paths on imports, for nextjs projects with typescript enable. To reproduce, follow the steps: run npm init next-app to create an

Zeit (Vercel) Now serverless authenticated requests failing because of CORS

混江龙づ霸主 提交于 2020-05-29 02:39:11
问题 I'm not able to correctly handle CORS issues when doing either PATCH / POST / PUT requests from the browser sending an Authorization header with a Bearer token (this works correctly outside of the browser and for GET requests) in Zeit Now serverless. I'm using Auth0 for the authorization side if that helps. This is my now.json headers section, I've tried a lot of combinations for these, but neither succeeded from the browser. I tried using npm cors package without success Tried to add routes

Zeit (Vercel) Now serverless authenticated requests failing because of CORS

对着背影说爱祢 提交于 2020-05-29 02:39:03
问题 I'm not able to correctly handle CORS issues when doing either PATCH / POST / PUT requests from the browser sending an Authorization header with a Bearer token (this works correctly outside of the browser and for GET requests) in Zeit Now serverless. I'm using Auth0 for the authorization side if that helps. This is my now.json headers section, I've tried a lot of combinations for these, but neither succeeded from the browser. I tried using npm cors package without success Tried to add routes