https://drive.google.com/file/d/11bH1kTdckq6lz_s0Q9WpF0hXsZZ9Hw7H/view?usp=sharing
Created
February 11, 2024 19:01
-
-
Save youtube-jocoding/c564f1ad4c08aa12cbfd0f42e090c8ba to your computer and use it in GitHub Desktop.
코드 ctrl + c, ctrl + v 했는데 안되네요 ㅠㅠ
배포까지 했는데요.
다음과 같이 에러 로그 뜨면서 안되네요 ;;
https://chatdoge-yoonhok.pages.dev' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
backend 코드는 다음과 같고요.
제가 뭘 놓친 걸까요...?
책에 나온대로 한다고 한 것 같은데요 ㅠㅠ
require('dotenv').config();
const OpenAI = require('openai');
const client = new OpenAI({
apiKey: process.env.API_KEY_OPENAI
});
const serverless = require('serverless-http')
const express = require('express');
const app = express();
const cors = require('cors');
const corsOptions = {
origin: 'https://chatdoge-yoonhok.pages.dev',
credentials: true
}
app.use(cors(corsOptions))
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.post('/fortuneTell', async function (req, res) {
...
})
module.exports.handler = serverless(app)
람다 배포 관련해서 무슨 API Gateway 설정 같은 걸 해야 하는 것 같은데요.
이게 누락되서 그런 건가요...?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cannot GET / 이라고 뜨는데 왜일까요