Fix SVG's not loading in multiplayer (#498)
* Session undefined * Fix S3 svg uploads
This commit is contained in:
parent
15784517e8
commit
f61c09fb55
3 changed files with 5 additions and 3 deletions
|
@ -4,7 +4,8 @@ export function useMultiplayerAssets() {
|
|||
const onAssetCreate = React.useCallback(
|
||||
async (file: File, id: string): Promise<string | false> => {
|
||||
const filename = encodeURIComponent(file.name)
|
||||
const res = await fetch(`/api/upload?file=${filename}`)
|
||||
const fileType = encodeURIComponent(file.type)
|
||||
const res = await fetch(`/api/upload?file=${filename}&fileType=${fileType}`)
|
||||
const { url, fields } = await res.json()
|
||||
const formData = new FormData()
|
||||
Object.entries({ ...fields, file }).forEach(([key, value]) => {
|
||||
|
|
|
@ -10,10 +10,11 @@ export default async function handler(req, res) {
|
|||
|
||||
const s3 = new aws.S3()
|
||||
|
||||
const post = await s3.createPresignedPost({
|
||||
const post = s3.createPresignedPost({
|
||||
Bucket: process.env.TL_AWS_BUCKET_NAME,
|
||||
Fields: {
|
||||
key: req.query.file,
|
||||
'Content-Type': req.query.fileType,
|
||||
},
|
||||
Expires: 60, // seconds
|
||||
Conditions: [
|
||||
|
|
|
@ -21,7 +21,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
|
|||
props: {
|
||||
id,
|
||||
isUser: session?.user ? true : false,
|
||||
isSponsor: session?.isSponsor,
|
||||
isSponsor: session?.isSponsor ?? false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue