interface MutableRefObject<T> {
prev?: null | HTMLParagraphElement;
}const ref: MutableRefObject<null | HTMLParagraphElement> = useRef(null)
ref.prev = nullType 'MutableRefObject<null>' has no properties in common with type 'MutableRefObject<HTMLParagraphElement | null>'interface MySuperMutableRefObject extends MutableRefObject<T> {
prev?: null | HTMLParagraphElement;
}Cannot find name 'T'.const ref: MySuperMutableRefObject = useRef(null)
ref.prev = null разумно
Не использовать serial и ON CONFLICT на таблицах с ожидаемо существенным количеством конфликтующих вставок. app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
console.log('middleware has been done')
next()
})app.post('/user', (req, res) => {
res.send(JSON.stringify('hello world'))
}) app.user(cors()), то работает, а без него, не хочет// app.use(cors())app.post('/user', cors(), (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
res.send(JSON.stringify('hello world'))
})app.post('/user', (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*')
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
res.send(JSON.stringify('hello world'))
}) router.post('/', async function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:5173')
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
next()
res.send('hello world')
});Access to fetch at 'http://localhost:3000/user' from origin 'http://localhost:5173' 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. const response = await fetch('http://localhost:3000/user', {
method: 'POST',
body: JSON.stringify(data.current),
headers: {
'Content-Type': 'application/json'
}
})Access to fetch at 'http://localhost:3000/user' from origin 'http://localhost:5173' 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.
Тут по факту ругается только TS, в JS все четко с таким подходом.
И тут хочется понять, как в вообще расширять такие интерфейсы и почему он не расширяется классическими способами