小编Sub*_*ndu的帖子

如何修复 nextjs cloudfront 静态资产响应 403?

我正在尝试使用 cloudfront 和 route53 将我的网站部署到 aws。该站点在https://higgle.io上部署和运行 但是资产没有加载,因为图像抛出 403。我该如何解决?我正在使用无服务器serverless-next.js。我正在关注他们的一篇博客文章来设置它。到目前为止,我serverless.yml在路由级别添加了 which 。

higgle:
 component: serverless-next.js
Run Code Online (Sandbox Code Playgroud)

我的 next.config.js 看起来像

module.exports = {
  target: 'serverless',
  webpack: (config) => {
    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    });
    return config
  }
}
Run Code Online (Sandbox Code Playgroud)

虽然文件夹结构看起来像

-root
  -.next
  -pages
    -_document.js
    -index.js
  -public
    -static
      -favicon.ico
  -next.config.js
  -package.json
  -serverless.yml
Run Code Online (Sandbox Code Playgroud)

知道如何解决这个问题吗?谢谢

amazon-s3 amazon-web-services amazon-cloudfront serverless-framework serverless

5
推荐指数
1
解决办法
2566
查看次数

为什么react-select的菜单选择的setState使模态关闭状态?

我有一个模态,它监听模态的外部点击并触发关闭模态的 onclose 方法。现在,我将反应选择添加到模式中,选择其中一个选项后,它使我的模式进入关闭状态。我正在从一篇媒体文章中捕获外部点击。

function useOuterClickNotifier(onOuterClick, innerRef) {
  useEffect(() => {
    if (innerRef.current) {
      document.addEventListener("click", handleClick);
    }
    return () => document.removeEventListener("click", handleClick);

    function handleClick(e) {
      if (innerRef.current && !innerRef.current.contains(e.target)) {
        onOuterClick(e);
      }
    }
  }, [onOuterClick, innerRef]);
}

Run Code Online (Sandbox Code Playgroud)

https://medium.com/@pitipatdop/little-neat-trick-to-capture-click-outside-with-react-hook-ba77c37c7e82

我的index.js

import React, { useState } from "react";
import ReactDOM from "react-dom";
import "./styles.css";
import Select from "react-select";
import Modal from "../Modal";

const options = [
  { value: "chocolate", label: "Chocolate" },
  { value: "strawberry", label: "Strawberry" },
  { value: "vanilla", label: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-select

4
推荐指数
1
解决办法
1571
查看次数

如何为矩形的对角线设置动画?

我正在尝试对角线添加动画。我知道的矩形的高度和宽度(动态累加)。现在尝试从N到L,或从O到M或其他方式设置一条线的动画。我尝试使用svg并增加了行的x1,y1,x2,y2,但这变得越来越复杂。任何更简单的解决方案?

在此处输入图片说明

html css animation svg css3

3
推荐指数
1
解决办法
140
查看次数

在 react ssr 应用程序中调用 firebase 消息传递方法时,如何修复 self 未定义?

我正在尝试在使用https://github.com/jaredpalmer/razzle with-react-router-3创建的 SSR 应用程序中使用 firebase 按摩。我已经在使用 Firebase,它非常有效,包括托管。但是当我开始在应用程序中添加消息时开始抛出错误。

我的入口点看起来像,

import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/storage';
import 'firebase/firestore';
import 'firebase/messaging';

import FirebaseConfig from 'config/firebase-config.json';
if (!firebase.apps.length) {
  firebase.initializeApp(FirebaseConfig);
}
const messaging = firebase.messaging();
Run Code Online (Sandbox Code Playgroud)

当我使用以下命令启动服务器时出现以下错误 razzle start

/Users/subkundu/Desktop/Work/Projects/React/ownerstown/node_modules/@firebase/messaging/index.ts:75
  if (self && 'ServiceWorkerGlobalScope' in self) {
  ^

ReferenceError: self is not defined
Run Code Online (Sandbox Code Playgroud)

我如何解决它?任何领先都将是惊人的。谢谢。:)

firebase reactjs firebase-cloud-messaging react-ssr razzle

3
推荐指数
1
解决办法
2371
查看次数