yisibell / nuxt-proxy-request

A http proxy module for nuxt(3) powered by h3-proxy.
12 stars 0 forks source link

Vercel Proxy Issue #1

Open JMKelley opened 1 year ago

JMKelley commented 1 year ago

I'm using a proxy in my nuxt local environment, which I was hoping to deploy to Vercel. API call works nicely on my localhost, but when deployed to Vercel, I get a 403 Forbidden error. API key is all fine.

nuxt.config.js:

  proxy: {
    options: [
      {
        target: 'https://apiurl.ai/api/inference',
        pathFilter: ['/api**'],
        pathRewrite: {
          '^/api': ''
        }
      }

When doing a POST request on Vercel I get the error:

[403] - POST https://myapp.vercel.app/api?access_token=xxxxxx&model_id=RR6lMmw

Unsure if this is a Vercel issue or a nuxt proxy request issue?

Any help would be great.

yisibell commented 1 year ago

It may be due to the incorrect value of nitro preset. Please set it to vercel instead of vercel-edge.

import { defineNuxtConfig } from 'nuxt/config'
export default defineNuxtConfig({
  // ...
  nitro: {
    preset: 'vercel', // Do not use `vercel-edge`
  },
  // ...
})

And, here a example project for deploy on vercel: https://github.com/yisibell/nuxt3-vercel-app-example

You can see http request demo here.

JMKelley commented 1 year ago

Thanks for the support. Yep, it's a nuxt 3 project. Gave what you said a try but it's still causing errors in the PUT request. Works beautifully on my localhost.

yisibell commented 1 year ago

It seems that this API ·POST https://myapp.vercel.app/api?access_token=xxxxxx&model_id=RR6lMmw itself does not support non GET requests. Can you provide the address of the Vercel project you are deploying.